[Numpy-discussion] New numpy functions: filled, filled_like
Benjamin Root
ben.root@ou....
Mon Jan 14 13:05:21 CST 2013
On Mon, Jan 14, 2013 at 1:56 PM, David Warde-Farley <
d.warde.farley@gmail.com> wrote:
> On Mon, Jan 14, 2013 at 1:12 PM, Pierre Haessig
> <pierre.haessig@crans.org> wrote:
> > In [8]: tile(nan, (3,3)) # (it's a verb ! )
>
> tile, in my opinion, is useful in some cases (for people who think in
> terms of repmat()) but not very NumPy-ish. What I'd like is a function
> that takes
>
> - an initial array_like "a"
> - a shape "s"
> - optionally, a dtype (otherwise inherit from a)
>
> and broadcasts "a" to the shape "s". In the case of scalars this is
> just a fill. In the case of, say, a (5,) vector and a (10, 5) shape,
> this broadcasts across rows, etc.
>
> I don't think it's worth special-casing scalar fills (except perhaps
> as an implementation detail) when you have rich broadcasting semantics
> that are already a fundamental part of NumPy, allowing for a much
> handier primitive.
>
I have similar problems with "tile". I learned it for a particular use in
numpy, and it would be hard for me to see it for another (contextually)
different use.
I do like the way you are thinking in terms of the broadcasting semantics,
but I wonder if that is a bit awkward. What I mean is, if one were to use
broadcasting semantics for creating an array, wouldn't one have just simply
used broadcasting anyway? The point of broadcasting is to _avoid_ the
creation of unneeded arrays. But maybe I can be convinced with some
examples.
Ben Root
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130114/9f835fa9/attachment.html
More information about the NumPy-Discussion
mailing list