[Numpy-discussion] Add a function to broadcast arrays to a given shape to numpy's stride_tricks?

Stephan Hoyer shoyer at gmail.com
Wed Dec 10 03:10:23 EST 2014


On Sun, Dec 7, 2014 at 11:31 PM, Pierre Haessig <pierre.haessig at crans.org>
wrote:

> Instead of putting this function in stride_tricks (which is quite
> hidden), could it be added instead as a boolean flag to the existing
> `reshape` method ? Something like:
>
> x.reshape(y.shape, broadcast=True)
>
> What other people think ?
>

I agree that it would be nice to expose this more directly, but I see two
(small) downsides to putting this in reshape:
1. This would one of those flags that changes a method to an entirely
different mode -- there's not much the way of shared logic with reshape.
2. reshape is written in C (like all ndarray methods, I believe), so
implementing this there will be a little trickier than adding a new
function.

Cheers,
Stephan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20141210/c45f9e54/attachment.html>


More information about the NumPy-Discussion mailing list