From 321ea752a3c48d696b8b776fa283bf2064b4fd47 Mon Sep 17 00:00:00 2001 From: Ryan May Date: Sat, 2 Dec 2023 20:53:18 -0700 Subject: [PATCH] Avoid numpy scalar warnings (#1880) NumPy as of 1.25 deprecated automatically converting any "scalar" with non-zero number of dimensions to a float value. Therefore, we should ensure our values have ndim == 0 before passing to math.isnan() --- pint/facets/numpy/quantity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pint/facets/numpy/quantity.py b/pint/facets/numpy/quantity.py index 5257766bc..9039a1f85 100644 --- a/pint/facets/numpy/quantity.py +++ b/pint/facets/numpy/quantity.py @@ -266,7 +266,7 @@ def __setitem__(self, key, value): isinstance(self._magnitude, np.ma.MaskedArray) and np.ma.is_masked(value) and getattr(value, "size", 0) == 1 - ) or math.isnan(value): + ) or (getattr(value, "ndim", 0) == 0 and math.isnan(value)): self._magnitude[key] = value return except TypeError: