[Numpy-discussion] numpy.filled, again

Chris Barker - NOAA Federal chris.barker at noaa.gov
Wed Jun 12 12:36:28 EDT 2013


On Wed, Jun 12, 2013 at 5:10 AM, Nathaniel Smith <njs at pobox.com> wrote:

> Personally I think that overloading np.empty is horribly ugly, will
> continue confusing newbies and everyone else indefinitely, and I'm
> 100% convinced that we'll regret implementing such a warty interface
> for something that should be so idiomatic.
...
 deprecate np.ma.filled in favor
> of masked_array.filled (which does exactly the same thing) and
> eventually switch np.ma.filled to be consistent with the new
> np.filled.

+1

> I also don't really see why an np.empty() constructor exists, it seems
> to do the same thing that np.ndarray() does.

I had always assumed that np.ndarray() was a "low-level" interce that
you really don't want to use in regular code (maybe for subclassing
array...), as the docs say:

"""
Arrays should be constructed using `array`, `zeros` or `empty` (refer
to the See Also section below).  The parameters given here refer to
a low-level method (`ndarray(...)`) for instantiating an array.
"""

Am I wrong? is there any reason )other than history to have np.empty()

But in any case, I like np.filled(), as being analogous to ones(),
zeros() and empty()...

-Chris





-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov



More information about the NumPy-Discussion mailing list