From 655e3daaf01dba4d571901d228398ddd65b8def0 Mon Sep 17 00:00:00 2001 From: andrewgsavage Date: Tue, 21 May 2024 21:45:22 +0200 Subject: [PATCH] offsets as deltas --- pint/facets/numpy/numpy_func.py | 6 +++--- pint/testsuite/test_numpy.py | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pint/facets/numpy/numpy_func.py b/pint/facets/numpy/numpy_func.py index e59205be6..8b95fb322 100644 --- a/pint/facets/numpy/numpy_func.py +++ b/pint/facets/numpy/numpy_func.py @@ -1004,8 +1004,6 @@ def implementation(a, *args, **kwargs): # Handle functions with output unit defined by operation for func_str in ( - "std", - "nanstd", "sum", "nansum", "cumsum", @@ -1013,7 +1011,9 @@ def implementation(a, *args, **kwargs): "linalg.norm", ): implement_func("function", func_str, input_units=None, output_unit="sum") -for func_str in ("diff", "ediff1d"): +for func_str in ("diff", "ediff1d", + "std", + "nanstd",): implement_func("function", func_str, input_units=None, output_unit="delta") for func_str in ("gradient",): implement_func("function", func_str, input_units=None, output_unit="delta,div") diff --git a/pint/testsuite/test_numpy.py b/pint/testsuite/test_numpy.py index 19a28b248..e4059ccf4 100644 --- a/pint/testsuite/test_numpy.py +++ b/pint/testsuite/test_numpy.py @@ -850,11 +850,14 @@ def test_nanmedian_numpy_func(self): assert np.nanmedian(self.q_nan) == 2 * self.ureg.m def test_var(self): + assert self.q.var() == 1.25 * self.ureg.m**2 assert self.q_temperature.var() == 1.25 * self.ureg.delta_degC**2 @helpers.requires_array_function_protocol() def test_var_numpy_func(self): assert np.var(self.q) == 1.25 * self.ureg.m**2 + assert np.var(self.q_temperature) == 1.25 * self.ureg.delta_degC**2 + @helpers.requires_array_function_protocol() def test_nanvar_numpy_func(self):