[Numpy-discussion] Add a function to broadcast arrays to a given shape to numpy's stride_tricks?
Sebastian Berg
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.
> > > >
> > > >
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.broadcast.html
> > > 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
> copy=True
> > 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
> implemented
> > in C, and may be willing to help with it. This kind of code exists
> in
> > enough places in numpy so it can be stolen pretty readily. One
> option
> > 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
> two.
>
> 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.
- Sebastian
> --
> Robert Kern
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20141212/0b88f119/attachment.sig>
More information about the NumPy-Discussion
mailing list