[Numpy-discussion] New numpy functions: filled, filled_like

Benjamin Root ben.root at ou.edu
Mon Jan 14 09:57:17 EST 2013


On Mon, Jan 14, 2013 at 7:38 AM, Pierre Haessig <pierre.haessig at crans.org>wrote:

> Hi,
>
> Le 14/01/2013 00:39, Nathaniel Smith a écrit :
> > (The nice thing about np.filled() is that it makes np.zeros() and
> > np.ones() feel like clutter, rather than the reverse... not that I'm
> > suggesting ever getting rid of them, but it makes the API conceptually
> > feel smaller, not larger.)
> Coming from the Matlab syntax, I feel that np.zeros and np.ones are in
> numpy for Matlab (and maybe others ?) compatibilty and are useful for
> that. Now that I've been "enlightened" by Python, I think that those
> functions (especially np.ones) are indeed clutter. Therefore I favor the
> introduction of these two new functions.
>
> However, I think Eric's remark about masked array API compatibility is
> important. I don't know what other names are possible ? np.const ?
>
> Or maybe np.tile is also useful for that same purpose ? In that case
> adding a dtype argument to np.tile would be useful.
>
> best,
> Pierre
>
>
I am also +1 on the idea of having a filled() and filled_like() function (I
learned a long time ago to just do a = np.empty() and a.fill() rather than
the multiplication trick I learned from Matlab).  However, the collision
with the masked array API is a non-starter for me.  np.const() and
np.const_like() probably make the most sense, but I would prefer a verb
over a noun.

Ben Root
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130114/ff2d25e4/attachment.html>


More information about the NumPy-Discussion mailing list