8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9618fc6 commit 5b2efbcCopy full SHA for 5b2efbc
lib/matplotlib/tests/test_units.py
@@ -282,8 +282,16 @@ class Kernel:
282
def __init__(self, array):
283
self._array = np.asanyarray(array)
284
285
- def __array__(self):
286
- return self._array
+ def __array__(self, dtype=None, copy=None):
+ if dtype is not None and dtype != self._array.dtype:
287
+ if copy is not None and not copy:
288
+ raise ValueError(
289
+ f"Converting array from {self._array.dtype} to "
290
+ f"{dtype} requires a copy"
291
+ )
292
+
293
+ arr = np.asarray(self._array, dtype=dtype)
294
+ return (arr if not copy else np.copy(arr))
295
296
@property
297
def shape(self):
0 commit comments