You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In-place addition and other in-place operations on masked arrays where the mask is not nomask results in an ufunc casting rule check which is not performed when the operation is performed normally (not in-place) or on a normal ndarray.
Example
>>>importnumpyasnp>>>x=np.ma.array([0, 1, 2], dtype='uint8', mask=False)
>>>x+=4Traceback (mostrecentcalllast):
File"<stdin>", line1, in<module>File"/home/jhelmus/anaconda/lib/python3.5/site-packages/numpy/ma/core.py", line4025, in__iadd__getdata(other)))
TypeError: Cannotcastufuncaddoutputfromdtype('int64') todtype('uint8') withcastingrule'same_kind'>>># Not in place>>>x=x+4>>># on a normal ndarray>>>x=np.array([0, 1, 2], dtype='uint8')
>>>x+=4