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

Skip to content

Commit 4e8972d

Browse files
committed
FIX: QuantityND should return NotImplemented rather than raise
__array_ufunc__ should "return" rather than "raise" when something is not handled within it.
1 parent cd66bfd commit 4e8972d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/matplotlib/tests/test_image.py

Lines changed: 3 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")
@@ -1184,10 +1184,10 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
11841184
elif ufunc == np.divide:
11851185
unit = f"{u0}/({u1})"
11861186
else:
1187-
raise NotImplementedError
1187+
return NotImplemented
11881188
out_arr = func(i0.view(np.ndarray), i1.view(np.ndarray), **kwargs)
11891189
else:
1190-
raise NotImplementedError
1190+
return NotImplemented
11911191
if unit is None:
11921192
out_arr = np.array(out_arr)
11931193
else:

0 commit comments

Comments
 (0)