8000 Merge pull request #21977 from greglucas/masked_ufunc · numpy/numpy@cb28cd1 · GitHub
[go: up one dir, main page]

Skip to content

Commit cb28cd1

Browse files
authored
Merge pull request #21977 from greglucas/masked_ufunc
ENH: Adding __array_ufunc__ capability to MaskedArrays
2 parents b8192d1 + db1a98b commit cb28cd1

File tree

6 files changed

+268
-48
lines changed

6 files changed

+268
-48
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MaskedArray gains a ``__array_ufunc__`` method to better handle ufuncs
2+
----------------------------------------------------------------------
3+
The MaskedArray class now has an implementation of `__array_ufunc__` that
4+
handles deferrals to the desired implementations of the ufunc. If a masked
5+
implementation of a ufunc exists, that implementation will take priority.
6+
This means that code called with MaskedArray ma as ``np.ufunc(ma)`` will
7+
behave the same as ``np.ma.ufunc(ma)``. Additionally, adding this helps with
8+
dispatching to subclasses and preserving the proper types when another
9+
implementation should take priority.

numpy/lib/tests/test_function_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ def test_subclass(self):
780780
mask=[[False, False], [True, False],
781781
[False, True], [True, True], [False, False]])
782782
out = diff(x)
783-
assert_array_equal(out.data, [[1], [1], [1], [1], [1]])
783+
assert_array_equal(out.data, [[1], [4], [6], [8], [1]])
784784
assert_array_equal(out.mask, [[False], [True],
785785
[True], [True], [False]])
786786
assert_(type(out) is type(x))

0 commit comments

Comments
 (0)
0