(self, func, dtype)
| 4111 | ids=repr, |
| 4112 | ) |
| 4113 | def test_aggregation(self, func, dtype): |
| 4114 | unit_a, unit_b = ( |
| 4115 | (unit_registry.Pa, unit_registry.degK) |
| 4116 | if func.name != "cumprod" |
| 4117 | else (unit_registry.dimensionless, unit_registry.dimensionless) |
| 4118 | ) |
| 4119 | |
| 4120 | a = np.linspace(0, 1, 10).astype(dtype) * unit_a |
| 4121 | b = np.linspace(-1, 0, 10).astype(dtype) * unit_b |
| 4122 | |
| 4123 | ds = xr.Dataset({"a": ("x", a), "b": ("x", b)}) |
| 4124 | |
| 4125 | if "dim" in func.kwargs: |
| 4126 | numpy_kwargs = func.kwargs.copy() |
| 4127 | dim = numpy_kwargs.pop("dim") |
| 4128 | |
| 4129 | axis_a = ds.a.get_axis_num(dim) |
| 4130 | axis_b = ds.b.get_axis_num(dim) |
| 4131 | |
| 4132 | numpy_kwargs_a = numpy_kwargs.copy() |
| 4133 | numpy_kwargs_a["axis"] = axis_a |
| 4134 | numpy_kwargs_b = numpy_kwargs.copy() |
| 4135 | numpy_kwargs_b["axis"] = axis_b |
| 4136 | else: |
| 4137 | numpy_kwargs_a = {} |
| 4138 | numpy_kwargs_b = {} |
| 4139 | |
| 4140 | units_a = array_extract_units(func(a, **numpy_kwargs_a)) |
| 4141 | units_b = array_extract_units(func(b, **numpy_kwargs_b)) |
| 4142 | units = {"a": units_a, "b": units_b} |
| 4143 | |
| 4144 | actual = func(ds) |
| 4145 | expected = attach_units(func(strip_units(ds)), units) |
| 4146 | |
| 4147 | assert_units_equal(expected, actual) |
| 4148 | assert_allclose(expected, actual) |
| 4149 | |
| 4150 | @pytest.mark.parametrize("property", ("imag", "real")) |
| 4151 | def test_numpy_properties(self, property, dtype): |
nothing calls this directly
no test coverage detected