Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MNT: Update basic units example to work with numpy 2.0 #28441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions galleries/examples/units/basic_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down