[Numpy-discussion] numpy.filled, again

Warren Weckesser warren.weckesser@gmail....
Wed Jun 12 13:13:16 CDT 2013


On Wed, Jun 12, 2013 at 2:00 PM, Nathaniel Smith <njs@pobox.com> wrote:

> On 12 Jun 2013 18:20, "Ralf Gommers" <ralf.gommers@gmail.com> wrote:
> >
> >
> >
> >
> > On Wed, Jun 12, 2013 at 6:36 PM, Chris Barker - NOAA Federal <
> chris.barker@noaa.gov> wrote:
> >>
> >> On Wed, Jun 12, 2013 at 5:10 AM, Nathaniel Smith <njs@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.
> >
> >
> > I agree.
>
> Sounds like we're pretty much reaching consensus. Phew.
>
> >>
> >> ...
> >>  deprecate np.ma.filled
> >
> >
> > Please don't. Rather just live with the inconsistency between numpy and
> numpy.ma APIs. If that bothers you, just tell yourself that we'll get an
> NA dtype at some point and that that will make numpy.ma much less
> important:)
>
> Oh, I do tell myself that :-). With my committer/consensus-building hat
> on, np.ma has users, so I want something they can live with, and was
> suggesting some options. For myself I don't really care what np.ma does
> though since I don't use it...
>
> >> 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()...
> >
> >
> > I like np.filled as well. np.fill_with sounds fine too.
>
> Grammatically, fill_with is an imperative, which suggests it needs an
> array to operate on; it's synonymous with just plain 'fill'. Having 'fill'
> and 'fill_with' as different functions with different semantics would be
> pretty confusing!
>
>
That's why I suggested 'filledwith' (add the underscore if you like).  This
also allows a corresponding masked implementation, 'ma.filledwith', without
clobbering the existing 'ma.filled'.

Warren

-n
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130612/efd6ab9e/attachment.html 


More information about the NumPy-Discussion mailing list