diff --git a/lib/matplotlib/tests/test_units.py b/lib/matplotlib/tests/test_units.py index fa8e5709db64..a5fd32dfb3e5 100644 --- a/lib/matplotlib/tests/test_units.py +++ b/lib/matplotlib/tests/test_units.py @@ -282,8 +282,16 @@ class Kernel: def __init__(self, array): self._array = np.asanyarray(array) - def __array__(self): - return self._array + def __array__(self, dtype=None, copy=None): + if dtype is not None and dtype != self._array.dtype: + if copy is not None and not copy: + raise ValueError( + f"Converting array from {self._array.dtype} to " + f"{dtype} requires a copy" + ) + + arr = np.asarray(self._array, dtype=dtype) + return (arr if not copy else np.copy(arr)) @property def shape(self):
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: