From 2b3d142d24daa73e90e21ce095c790dd8632e512 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 14 Aug 2024 21:34:38 -0400 Subject: [PATCH 1/3] FIX: remove __array__ method on BasicUnit The presence of this method causes the numpy float __mul__ to use it in numpy 2.1 which results in the units not being tagged as expected and the example failing. --- galleries/examples/units/basic_units.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/galleries/examples/units/basic_units.py b/galleries/examples/units/basic_units.py index 3f64d145b65e..2710c6163bb5 100644 --- a/galleries/examples/units/basic_units.py +++ b/galleries/examples/units/basic_units.py @@ -147,9 +147,6 @@ def __getattribute__(self, name): return getattr(variable, name) return object.__getattribute__(self, name) - def __array__(self, dtype=object, copy=False): - return np.asarray(self.value, dtype) - def __array_wrap__(self, array, context=None, return_scalar=False): return TaggedValue(array, self.unit) From b4ab05d5a18f710cb78f6c87864f12ba4130840a Mon Sep 17 00:00:00 2001 From: Kyle Sunden Date: Wed, 21 Aug 2024 15:20:51 -0500 Subject: [PATCH 2/3] Remove __array__ from BasicUnit --- galleries/examples/units/basic_units.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/galleries/examples/units/basic_units.py b/galleries/examples/units/basic_units.py index 2710c6163bb5..b104d887a6dc 100644 --- a/galleries/examples/units/basic_units.py +++ b/galleries/examples/units/basic_units.py @@ -223,13 +223,6 @@ def __rmul__(self, lhs): def __array_wrap__(self, array, context=None, return_scalar=False): return TaggedValue(array, self) - def __array__(self, t=None, context=None, copy=False): - ret = np.array(1) - if t is not None: - return ret.astype(t) - else: - return ret - def add_conversion_factor(self, unit, factor): def convert(x): return x*factor From 108565a10f924df3170a7a785c8959bc866f0d60 Mon Sep 17 00:00:00 2001 From: Kyle Sunden Date: Wed, 21 Aug 2024 16:04:02 -0500 Subject: [PATCH 3/3] Update missing references for moved lines --- doc/missing-references.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/missing-references.json b/doc/missing-references.json index a93a03b6ef73..87c9ce9b716f 100644 --- a/doc/missing-references.json +++ b/doc/missing-references.json @@ -356,7 +356,7 @@ "lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.gci:4" ], "Line2D.pick": [ - "doc/users/explain/figure/event_handling.rst:568" + "doc/users/explain/figure/event_handling.rst:571" ], "QuadContourSet.changed()": [ "lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.contour:156", @@ -365,7 +365,7 @@ "lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.contourf:156" ], "Rectangle.contains": [ - "doc/users/explain/figure/event_handling.rst:280" + "doc/users/explain/figure/event_handling.rst:285" ], "Size.from_any": [ "lib/mpl_toolkits/axes_grid1/axes_grid.py:docstring of mpl_toolkits.axes_grid1.axes_grid.ImageGrid:87",