(self, func, dtype)
| 2407 | ids=repr, |
| 2408 | ) |
| 2409 | def test_aggregation(self, func, dtype): |
| 2410 | array = np.arange(10).astype(dtype) * ( |
| 2411 | unit_registry.m if func.name != "cumprod" else unit_registry.dimensionless |
| 2412 | ) |
| 2413 | data_array = xr.DataArray(data=array, dims="x") |
| 2414 | |
| 2415 | numpy_kwargs = func.kwargs.copy() |
| 2416 | if "dim" in numpy_kwargs: |
| 2417 | numpy_kwargs["axis"] = data_array.get_axis_num(numpy_kwargs.pop("dim")) |
| 2418 | |
| 2419 | # units differ based on the applied function, so we need to |
| 2420 | # first compute the units |
| 2421 | units = extract_units(func(array)) |
| 2422 | expected = attach_units(func(strip_units(data_array)), units) |
| 2423 | actual = func(data_array) |
| 2424 | |
| 2425 | assert_units_equal(expected, actual) |
| 2426 | assert_allclose(expected, actual) |
| 2427 | |
| 2428 | @pytest.mark.parametrize( |
| 2429 | "func", |
nothing calls this directly
no test coverage detected