From 05d081fed47181eaf69ef4715cbe115050dcd3d8 Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Sun, 23 Jun 2024 14:57:28 -0600 Subject: [PATCH] MNT: Update basic units example to work with numpy 2.0 There are new keyword arguments required for __array__ and __array_wrap__ that are expected in numpy 2.0. --- galleries/examples/units/basic_units.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/galleries/examples/units/basic_units.py b/galleries/examples/units/basic_units.py index 0b493ab7216c..f9a94bcf6e37 100644 --- a/galleries/examples/units/basic_units.py +++ b/galleries/examples/units/basic_units.py @@ -146,10 +146,10 @@ def __getattribute__(self, name): return getattr(variable, name) return object.__getattribute__(self, name) - def __array__(self, dtype=object): + def __array__(self, dtype=object, copy=False): return np.asarray(self.value, dtype) - def __array_wrap__(self, array, context): + def __array_wrap__(self, array, context=None, return_scalar=False): return TaggedValue(array, self.unit) def __repr__(self): @@ -222,10 +222,10 @@ def __mul__(self, rhs): def __rmul__(self, lhs): return self*lhs - def __array_wrap__(self, array, context): + def __array_wrap__(self, array, context=None, return_scalar=False): return TaggedValue(array, self) - def __array__(self, t=None, context=None): + def __array__(self, t=None, context=None, copy=False): ret = np.array(1) if t is not None: return ret.astype(t)