From d331aafbc12b464baaf44745fd8e05ab756aa9e1 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 24 Dec 2023 05:34:44 +0000 Subject: [PATCH] check magnitude is array --- pint/facets/numpy/quantity.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pint/facets/numpy/quantity.py b/pint/facets/numpy/quantity.py index 5257766bc..561c1d31c 100644 --- a/pint/facets/numpy/quantity.py +++ b/pint/facets/numpy/quantity.py @@ -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):