[Numpy-discussion] Add a function to broadcast arrays to a given shape to numpy's stride_tricks?
njs at pobox.com
Thu Dec 11 09:47:09 EST 2014
On 11 Dec 2014 14:31, "Pierre Haessig" <pierre.haessig at crans.org> wrote:
> Le 11/12/2014 01:00, Nathaniel Smith a écrit :
> > Seems like a useful addition to me -- I've definitely wanted this in
> > the past. I agree with Stephan that reshape() might not be the best
> > place, though; I wouldn't think to look for it there.
> > Two API ideas, which are not mutually exclusive:
> > [...]
> > 2) Add a broadcast_to(arr, shape) function, which broadcasts the array
> > to exactly the shape given, or else errors out if this is not
> > possible.
> That's also possible. Then there could be a point in `reshape` docstring.
> Could this function be named `broadcast` instead of `broadcast_to` ?
> (in coherence with `reshape`)
It could, but then there wouldn't be much to distinguish it from
broadcast_arrays. Broadcasting is generally a symmetric operation - see
broadcast_arrays or arr1 + arr2. So the 'to' is there to give a clue that
this function is not symmetric, and rather has a specific goal in mind.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion