[Numpy-discussion] numpy.filled, again

Aldcroft, Thomas aldcroft@head.cfa.harvard....
Fri Jun 14 08:27:36 CDT 2013


On Thu, Jun 13, 2013 at 5:06 PM, <josef.pktd@gmail.com> wrote:

> On Thu, Jun 13, 2013 at 4:47 PM, Eric Firing <efiring@hawaii.edu> wrote:
> > On 2013/06/13 10:36 AM, Benjamin Root wrote:
> >>
> >> On Thu, Jun 13, 2013 at 9:36 AM, Aldcroft, Thomas
> >> <aldcroft@head.cfa.harvard.edu <mailto:aldcroft@head.cfa.harvard.edu>>
> >> wrote:
> >>
> >>
> >>
> >>
> >>     On Wed, Jun 12, 2013 at 2:55 PM, Eric Firing <efiring@hawaii.edu
> >>     <mailto:efiring@hawaii.edu>> wrote:
> >>
> >>         On 2013/06/12 8:13 AM, Warren Weckesser wrote:
> >>          > 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'.
> >>
> >>         Consensus on np.filled? absolutely not, you do not have a
> consensus.
> >>
> >>         np.filledwith or filled_with: fine with me, maybe even with
> >>         everyone--let's see.  I would prefer the underscore version.
> >>
> >>
> >>     +1 on np.filled_with.  It's unique the meaning is extremely obvious.
> >>       We do use np.ma.filled in astropy so a big -1 on deprecating that
> >>     (which would then require doing numpy version checks to get the
> >>     right method).  Even when there is an NA dtype the numpy.ma
> >>     <http://numpy.ma> users won't go away anytime soon.
> >>
> >>
> >> I like np.filled_with(), but just to be devil's advocate, think of the
> >> syntax:
> >>
> >> np.filled_with((10, 24), np.nan)
> >>
> >> As I read that, I am filling the array with (10, 24), not NaNs.  Minor
> >> issue, for sure, but just thought I raise that.
> >>
> >> -1 on deprecation of np.ma.filled().  -1 on np.filled() due to collision
> >> with np.ma <http://np.ma> (both conceptually and programatically).
> >>
> >> np.values() might be a decent alternative.
> >>
> >> Cheers!
> >> Ben Root
> >
> > Even if he is representing the devil, Ben raises a good point.  To
> > summarize, the most recent set of suggestions that seem not to have been
> > completely shot down include:
> >
> > np.filled_with((10, 24), np.nan)
> > np.full((10, 24), np.nan)          # analogous to np.empty
> > np.values((10, 24), np.nan)        # seems clear, concise
> > np.initialized((10, 24), np.nan)   # a few more characters, but
> >                                     #  seems clear to me.
> >
> > Personally, I like all of the last three better than the first.
>

What about:

  np.filled_array((10, 24), np.nan)

If I just saw np.values(..) in some code I would never guess what it is
doing from the name, and beyond that I would guess that I can put in
multiple "values" in the second arg.  np.initialized() is more obvious to
me.

- Tom

>
> np.values
> sounds also good to me, a noun like np.ones, np.nans, np.infs, np.zeros
>
> I don't like np.initialized because empty also initializes and array
> (although) an empty one.
>
> Josef
>
> >
> > Eric
> >
> >
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion@scipy.org
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
> _______________________________________________
> 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/20130614/cca06886/attachment.html 


More information about the NumPy-Discussion mailing list