A somewhat contrived example
>>> source = np.ma.masked # comes from user function, could be anything
>>> source = np.asanyarray(source) # force to array, so we can try to copy the type
>>> outarr = np.zeros((2, 2)) # allocate a raw ndarray for the result
>>> bad = source.__array_prepare__(outarr) # prepare that raw array for operations
>>> bad.shape
(2, 2)
>>> bad.data.shape
() # uh oh
>>> bad.mask.shape
() # spaghettios
Which leads to failures like
>>> res.transpose((1, 0))
Traceback (most recent call last):
File "<pyshell#78>", line 1, in <module>
np.asanyarray(np.ma.masked).__array_prepare__(np.zeros((2, 2))).transpose((1, 0))
File "C:\Program Files\Python 3.5\lib\site-packages\numpy\ma\core.py", line 2509, in wrapped_method
result = getattr(self._data, funcname)(*args, **params)
ValueError: axes don't match array
This come up when trying to invoke #8441 on masked arrays.
Is this a bug, or an invalid use of __array_prepare__?
A somewhat contrived example
Which leads to failures like
This come up when trying to invoke #8441 on masked arrays.
Is this a bug, or an invalid use of
__array_prepare__?