|
| 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