(self, raw_values, unit, error, dtype)
| 3403 | ), |
| 3404 | ) |
| 3405 | def test_drop_sel(self, raw_values, unit, error, dtype): |
| 3406 | array = np.linspace(5, 10, 20).astype(dtype) * unit_registry.m |
| 3407 | x = np.arange(len(array)) * unit_registry.m |
| 3408 | data_array = xr.DataArray(data=array, coords={"x": x}, dims="x") |
| 3409 | |
| 3410 | values = raw_values * unit |
| 3411 | |
| 3412 | if error is not None and not ( |
| 3413 | isinstance(raw_values, int | float) and x.check(unit) |
| 3414 | ): |
| 3415 | with pytest.raises(error): |
| 3416 | data_array.drop_sel(x=values) |
| 3417 | |
| 3418 | return |
| 3419 | |
| 3420 | expected = attach_units( |
| 3421 | strip_units(data_array).drop_sel( |
| 3422 | x=strip_units(convert_units(values, {None: x.units})) |
| 3423 | ), |
| 3424 | extract_units(data_array), |
| 3425 | ) |
| 3426 | actual = data_array.drop_sel(x=values) |
| 3427 | |
| 3428 | assert_units_equal(expected, actual) |
| 3429 | assert_identical(expected, actual) |
| 3430 | |
| 3431 | @pytest.mark.parametrize("dim", ("x", "y", "z", "t", "all")) |
| 3432 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected