[Numpy-discussion] Why does np.nan{min, max} clobber my array mask?

Pierre GM pgmdevlist@gmail....
Sun Feb 14 14:22:04 CST 2010

On Feb 13, 2010, at 10:04 PM, David Carmean wrote:
> I'm just starting to work with masked arrays and I've found some behavior that 
> definitely does not follow the Principle of Least Surprise:

A fuzzy concept ;)

> I've generated a 2-d array from a list of lists, where the elements are floats with 
> a good number of NaNs.  Inspections shows the expected numbers for ma.count() and 
> ma.count_masked().
> However, as soon as I run np.nanmin() or np.nanmax() over it, all of the mask elements 
> are reset to False.

I'm sorry, I can't follow you. Can you post a simpler self-contained example I can play with ?
Why using np.nanmin/max ? These functions are designed for ndarrays, to avoid using a masked array: can't you just use min/max on the masked array ?

More information about the NumPy-Discussion mailing list