(self, offset, fill_value, dtype)
| 4221 | @pytest.mark.parametrize("offset", [-5, 0, 1, 2]) |
| 4222 | @pytest.mark.parametrize("fill_value, dtype", [(2, int), (dtypes.NA, float)]) |
| 4223 | def test_shift(self, offset, fill_value, dtype) -> None: |
| 4224 | arr = DataArray([1, 2, 3], dims="x") |
| 4225 | actual = arr.shift(x=1, fill_value=fill_value) |
| 4226 | if fill_value == dtypes.NA: |
| 4227 | # if we supply the default, we expect the missing value for a |
| 4228 | # float array |
| 4229 | fill_value = np.nan |
| 4230 | expected = DataArray([fill_value, 1, 2], dims="x") |
| 4231 | assert_identical(expected, actual) |
| 4232 | assert actual.dtype == dtype |
| 4233 | |
| 4234 | arr = DataArray([1, 2, 3], [("x", ["a", "b", "c"])]) |
| 4235 | expected = DataArray(arr.to_pandas().shift(offset)) |
| 4236 | actual = arr.shift(x=offset) |
| 4237 | assert_identical(expected, actual) |
| 4238 | |
| 4239 | def test_roll_coords(self) -> None: |
| 4240 | arr = DataArray([1, 2, 3], coords={"x": range(3)}, dims="x") |
nothing calls this directly
no test coverage detected