Skip to content

Commit

Permalink
check magnitude is array
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgsavage committed Dec 24, 2023
1 parent f9e139e commit d331aaf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pint/facets/numpy/quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ def _numpy_method_wrap(self, func, *args, **kwargs):
return value

def __array__(self, t=None) -> np.ndarray:
warnings.warn(
"The unit of the quantity is stripped when downcasting to ndarray.",
UnitStrippedWarning,
stacklevel=2,
)
if isinstance(self._magnitude, np.ndarray):
warnings.warn(
"The unit of the quantity is stripped when downcasting to ndarray.",
UnitStrippedWarning,
stacklevel=2,
)
return _to_magnitude(self._magnitude, force_ndarray=True)

def clip(self, min=None, max=None, out=None, **kwargs):
Expand Down

0 comments on commit d331aaf

Please sign in to comment.