Skip to content

Commit

Permalink
Merge pull request #23528 from meeseeksmachine/auto-backport-of-pr-23…
Browse files Browse the repository at this point in the history
…523-on-v3.5.x

Backport PR #23523 on branch v3.5.x (TST: Update Quantity test class)
  • Loading branch information
timhoffm committed Jul 31, 2022
2 parents 88e7680 + 632e4d7 commit 952227e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/matplotlib/tests/test_image.py
Expand Up @@ -1170,7 +1170,7 @@ def __getitem__(self, item):
def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
func = getattr(ufunc, method)
if "out" in kwargs:
raise NotImplementedError
return NotImplemented
if len(inputs) == 1:
i0 = inputs[0]
unit = getattr(i0, "units", "dimensionless")
Expand All @@ -1190,11 +1190,16 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
unit = f"{u0}*{u1}"
elif ufunc == np.divide:
unit = f"{u0}/({u1})"
elif ufunc in (np.greater, np.greater_equal,
np.equal, np.not_equal,
np.less, np.less_equal):
# Comparisons produce unitless booleans for output
unit = None
else:
raise NotImplementedError
return NotImplemented
out_arr = func(i0.view(np.ndarray), i1.view(np.ndarray), **kwargs)
else:
raise NotImplementedError
return NotImplemented
if unit is None:
out_arr = np.array(out_arr)
else:
Expand Down

0 comments on commit 952227e

Please sign in to comment.