[Numpy-discussion] New numpy functions: filled, filled_like
Mon Jan 14 13:05:21 CST 2013
On Mon, Jan 14, 2013 at 1:56 PM, David Warde-Farley <
> On Mon, Jan 14, 2013 at 1:12 PM, Pierre Haessig
> <firstname.lastname@example.org> wrote:
> > In : 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)
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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion