(self, func, dtype)
| 1542 | ids=repr, |
| 1543 | ) |
| 1544 | def test_aggregation(self, func, dtype): |
| 1545 | array = np.linspace(0, 1, 10).astype(dtype) * ( |
| 1546 | unit_registry.m if func.name != "cumprod" else unit_registry.dimensionless |
| 1547 | ) |
| 1548 | variable = xr.Variable("x", array) |
| 1549 | |
| 1550 | numpy_kwargs = func.kwargs.copy() |
| 1551 | if "dim" in func.kwargs: |
| 1552 | numpy_kwargs["axis"] = variable.get_axis_num(numpy_kwargs.pop("dim")) |
| 1553 | |
| 1554 | units = extract_units(func(array, **numpy_kwargs)) |
| 1555 | expected = attach_units(func(strip_units(variable)), units) |
| 1556 | actual = func(variable) |
| 1557 | |
| 1558 | assert_units_equal(expected, actual) |
| 1559 | assert_allclose(expected, actual) |
| 1560 | |
| 1561 | def test_aggregate_complex(self): |
| 1562 | variable = xr.Variable("x", [1, 2j, np.nan] * unit_registry.m) |
nothing calls this directly
no test coverage detected