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

David Warde-Farley d.warde.farley@gmail....
Mon Jan 14 12:56:54 CST 2013

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.


More information about the NumPy-Discussion mailing list