On Tue, Dec 30, 2014 at 2:49 PM, Benjamin Root <ben.r...@ou.edu> wrote:

> Where does it say that operations on masked arrays should not produce NaNs?


Masked arrays were invented with the specific goal to avoid carrying NaNs
in computations.  Back in the days, NaNs were not available on some
platforms and had significant performance issues on others.  These days NaN
support for floating point types is nearly universal, but numpy types are
not limited by floating point.

> Having np.mean([]) return the same thing as np.ma.mean([]) makes complete
sense.

Does the following make sense as well?

>>> import numpy
>>> numpy.ma.masked_values([0, 0], 0).mean()
masked
>>> numpy.ma.masked_values([0], 0).mean()
masked
>>> numpy.ma.masked_values([], 0).mean()
* Two warnings *
masked_array(data = nan,
             mask = False,
       fill_value = 0.0)
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to