Skip to content

Commit 8092911

Browse files
committed
DOC: Added MA support for (numpy#21262)
1 parent c68a8b6 commit 8092911

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
``np.kron`` now maintains subclass information
2+
----------------------------------------------
3+
``np.kron`` maintains subclass information now such as masked arrays
4+
while computing the Kronecker product of the inputs
5+
6+
.. code-block:: python
7+
8+
>>> x = ma.array([[1, 2], [3, 4]], mask=[[0, 1], [1, 0]])
9+
>>> np.kron(x,x)
10+
masked_array(
11+
data=[[1, --, --, --],
12+
[--, 4, --, --],
13+
[--, --, 4, --],
14+
[--, --, --, 16]],
15+
mask=[[False, True, True, True],
16+
[ True, False, True, True],
17+
[ True, True, False, True],
18+
[ True, True, True, False]],
19+
fill_value=999999)
20+
21+
.. warning::
22+
``np.kron`` output now follows ``ufunc`` ordering (``multiply``)
23+
to determine the output class type
24+
25+
.. code-block:: python
26+
27+
>>> class myarr(np.ndarray):
28+
>>> __array_priority__ = -1
29+
>>> a = np.ones([2, 2])
30+
>>> ma = myarray(a.shape, a.dtype, a.data)
31+
>>> type(np.kron(a, ma)) == np.ndarray
32+
False # Before it was True
33+
>>> type(np.kron(a, ma)) == myarr
34+
True

0 commit comments

Comments
 (0)