(self, func, unit, error, dtype)
| 4200 | ), |
| 4201 | ) |
| 4202 | def test_numpy_methods_with_args(self, func, unit, error, dtype): |
| 4203 | data_unit = unit_registry.m |
| 4204 | a = np.linspace(0, 10, 15) * unit_registry.m |
| 4205 | b = np.linspace(-2, 12, 20) * unit_registry.m |
| 4206 | ds = xr.Dataset({"a": ("x", a), "b": ("y", b)}) |
| 4207 | units = extract_units(ds) |
| 4208 | |
| 4209 | kwargs = { |
| 4210 | key: array_attach_units(value, unit) for key, value in func.kwargs.items() |
| 4211 | } |
| 4212 | |
| 4213 | if error is not None: |
| 4214 | with pytest.raises(error): |
| 4215 | func(ds, **kwargs) |
| 4216 | |
| 4217 | return |
| 4218 | |
| 4219 | stripped_kwargs = { |
| 4220 | key: strip_units(convert_units(value, {None: data_unit})) |
| 4221 | for key, value in kwargs.items() |
| 4222 | } |
| 4223 | |
| 4224 | actual = func(ds, **kwargs) |
| 4225 | expected = attach_units(func(strip_units(ds), **stripped_kwargs), units) |
| 4226 | |
| 4227 | assert_units_equal(expected, actual) |
| 4228 | assert_equal(expected, actual) |
| 4229 | |
| 4230 | @pytest.mark.parametrize( |
| 4231 | "func", (method("isnull"), method("notnull"), method("count")), ids=repr |
nothing calls this directly
no test coverage detected