(dtype)
| 2159 | |
| 2160 | |
| 2161 | def test_slice(dtype) -> None: |
| 2162 | arr = xr.DataArray(["aafootwo", "aabartwo", "aabazqux"]).astype(dtype) |
| 2163 | |
| 2164 | result = arr.str.slice(2, 5) |
| 2165 | exp = xr.DataArray(["foo", "bar", "baz"]).astype(dtype) |
| 2166 | assert result.dtype == exp.dtype |
| 2167 | assert_equal(result, exp) |
| 2168 | |
| 2169 | for start, stop, step in [(0, 3, -1), (None, None, -1), (3, 10, 2), (3, 0, -1)]: |
| 2170 | try: |
| 2171 | result = arr.str[start:stop:step] |
| 2172 | expected = xr.DataArray([s[start:stop:step] for s in arr.values]) |
| 2173 | assert_equal(result, expected.astype(dtype)) |
| 2174 | except IndexError: |
| 2175 | print(f"failed on {start}:{stop}:{step}") |
| 2176 | raise |
| 2177 | |
| 2178 | |
| 2179 | def test_slice_broadcast(dtype) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…