[Numpy-discussion] Add a function to broadcast arrays to a given shape to numpy's stride_tricks?
sebastian at sipsolutions.net
Fri Dec 12 03:50:47 EST 2014
On Do, 2014-12-11 at 16:20 +0000, Robert Kern wrote:
> On Thu, Dec 11, 2014 at 4:17 PM, Sebastian Berg
> <sebastian at sipsolutions.net> wrote:
> > On Do, 2014-12-11 at 16:56 +0100, Pierre Haessig wrote:
> > > Le 11/12/2014 16:52, Robert Kern a écrit :
> > > >
> > > > And we already have a numpy.broadcast() function.
> > > >
> > > >
> > > True, I once read the docstring of this function. but never used
> it though.
> > I am not sure it is really the right thing for most things since it
> > returns an old style iterator.
> Indeed. That's why I wrote broadcast_arrays().
> > On the other hand arrays with 0-strides
> > need a bit more care (if we add this top level, one might have
> > as a default or so?).
> > Also because of that it is currently limited to NPY_MAXARGS (32).
> > Personally, I would like to see this type of functionality
> > in C, and may be willing to help with it. This kind of code exists
> > enough places in numpy so it can be stolen pretty readily. One
> > would also be to have something like:
> > np.common_shape(*arrays)
> > np.broadcast_to(array, shape)
> > # (though I would like many arrays too)
> > and then broadcast_ar rays could be implemented in terms of these
> Why? What benefit does broadcast_arrays() get from being reimplemented
> in C?
To be honest, maybe it is not. I remember that I had some function where
broadcast_arrays was the largest part of the runtime for smaller arrays
and I thought it should be easy since such code exists elsewhere.
> Robert Kern
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 819 bytes
Desc: This is a digitally signed message part
More information about the NumPy-Discussion