(self, raw_values, unit, error, dtype)
| 4940 | ), |
| 4941 | ) |
| 4942 | def test_drop_sel(self, raw_values, unit, error, dtype): |
| 4943 | array1 = np.linspace(5, 10, 20).astype(dtype) * unit_registry.degK |
| 4944 | array2 = np.linspace(0, 5, 20).astype(dtype) * unit_registry.Pa |
| 4945 | x = np.arange(len(array1)) * unit_registry.m |
| 4946 | |
| 4947 | ds = xr.Dataset( |
| 4948 | data_vars={ |
| 4949 | "a": xr.DataArray(data=array1, dims="x"), |
| 4950 | "b": xr.DataArray(data=array2, dims="x"), |
| 4951 | }, |
| 4952 | coords={"x": x}, |
| 4953 | ) |
| 4954 | |
| 4955 | values = raw_values * unit |
| 4956 | |
| 4957 | # TODO: if we choose dm as compatible unit, single value keys |
| 4958 | # can be found. Should we check that? |
| 4959 | if error is not None: |
| 4960 | with pytest.raises(error): |
| 4961 | ds.drop_sel(x=values) |
| 4962 | |
| 4963 | return |
| 4964 | |
| 4965 | expected = attach_units( |
| 4966 | strip_units(ds).drop_sel( |
| 4967 | x=strip_units(convert_units(values, {None: unit_registry.m})) |
| 4968 | ), |
| 4969 | extract_units(ds), |
| 4970 | ) |
| 4971 | actual = ds.drop_sel(x=values) |
| 4972 | |
| 4973 | assert_units_equal(expected, actual) |
| 4974 | assert_equal(expected, actual) |
| 4975 | |
| 4976 | @pytest.mark.skip(reason="indexes don't support units") |
| 4977 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected