[Numpy-discussion] array view with different shape

Mark Bakker markbak at gmail.com
Wed Sep 15 05:01:21 EDT 2010


Hello List,

Can I make a view of an entire array but with a different shape?

For example:

a = zeros((2,3,4))

Now I want array b to be identical to a, but with shape (2,12).

b = a; b.shape = (2,12)

This doesn't work, of course, as also the shape of a changes.
I know I can simply make a copy of a and change the shape, but can I make b
to be a view of a (so that when I change a, then b changes as well)?

Thanks,

Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100915/42ec74a3/attachment.html>


More information about the NumPy-Discussion mailing list