When a np.array (say a) is added with np.ma.masked_array (say ma) using a += ma operator, it gives a np.array output while a = a + ma gives a np.ma.maked_array output.
Reproducing code example:
>>> import numpy as np
>>> A = np.arange(10)
>>> ma = np.ma.masked_array(A, A>4)
>>> ma
masked_array(data=[0, 1, 2, 3, 4, --, --, --, --, --],
mask=[False, False, False, False, False, True, True, True,
True, True],
fill_value=999999)
>>> A += ma
>>> A
array([ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18])
>>> A = A + ma
>>> A
masked_array(data=[0, 4, 8, 12, 16, --, --, --, --, --],
mask=[False, False, False, False, False, True, True, True,
True, True],
fill_value=999999)
>>>
import numpy as np
<< your code here >>
Error message:
Numpy/Python version information:
>>> np.__version__
'1.18.4'
When a
np.array(saya) is added withnp.ma.masked_array(sayma) usinga += maoperator, it gives anp.arrayoutput whilea = a + magives anp.ma.maked_arrayoutput.Reproducing code example:
Error message:
Numpy/Python version information: