Skip to content

Commit

Permalink
Avoid numpy scalar warnings (#1880)
Browse files Browse the repository at this point in the history
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()
  • Loading branch information
dopplershift authored Dec 3, 2023
1 parent 7aa995c commit 321ea75
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pint/facets/numpy/quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 321ea75

Please sign in to comment.