Re: [Numpy-discussion] array view with different shape

2010-09-15 Thread Christopher Barker
Mark Bakker wrote: > Can I make a view of an entire array but with a different shape? yup. > 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. as

Re: [Numpy-discussion] array view with different shape

2010-09-15 Thread Pierre GM
On Sep 15, 2010, at 11:01 AM, Mark Bakker wrote: > Hello List, > > Can I make a view of an entire array but with a different shape? > > For example: > > a = zeros((2,3,4)) Mark, Try that. b = a.reshape((2,12)) Now, >>> b.flat=1 >>> a array([[[ 1., 1., 1., 1.], [ 1., 1., 1., 1

[Numpy-discussion] array view with different shape

2010-09-15 Thread Mark Bakker
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