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

Skip to content

Commit fa58d55

Browse files
authored
Merge pull request #23523 from greglucas/quantity-ufunc
TST: Update Quantity test class
2 parents cd66bfd + f716ea3 commit fa58d55

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/matplotlib/tests/test_image.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ def __getitem__(self, item):
11631163
def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
11641164
func = getattr(ufunc, method)
11651165
if "out" in kwargs:
1166-
raise NotImplementedError
1166+
return NotImplemented
11671167
if len(inputs) == 1:
11681168
i0 = inputs[0]
11691169
unit = getattr(i0, "units", "dimensionless")
@@ -1183,11 +1183,16 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
11831183
unit = f"{u0}*{u1}"
11841184
elif ufunc == np.divide:
11851185
unit = f"{u0}/({u1})"
1186+
elif ufunc in (np.greater, np.greater_equal,
1187+
np.equal, np.not_equal,
1188+
np.less, np.less_equal):
1189+
# Comparisons produce unitless booleans for output
1190+
unit = None
11861191
else:
1187-
raise NotImplementedError
1192+
return NotImplemented
11881193
out_arr = func(i0.view(np.ndarray), i1.view(np.ndarray), **kwargs)
11891194
else:
1190-
raise NotImplementedError
1195+
return NotImplemented
11911196
if unit is None:
11921197
out_arr = np.array(out_arr)
11931198
else:

0 commit comments

Comments
 (0)