So,
In [14]: x = zeros((2,3,4))
In [15]: rollaxis(x,0,3).shape
Out[15]: (3, 4, 2)
In [16]: rollaxis(x,0,2).shape
Out[16]: (3, 2, 4)
In [17]: rollaxis(x,0,1).shape
Out[17]: (2, 3, 4)
In [18]: rollaxis(x,0,0).shape
Out[18]: (2, 3, 4)
How come rollaxis(x,0,0) doesn't move 2 to the end ;) That's
Hi
I'm trying to split an array into two pieces and have the two pieces in a
new dimension.
Here it is in code, because that's hard to explain in words.
>>>data.shape
(4, 50, 3)
>>>new_data = numpy.zeros((2, 4, 25, 3))
>>>new_data[0,...] = data[:,:25,:]
>>>new_data[1,...] = data[:,25:,:]
>>>ne
> Generate a column-permutation tuple and use fancy indexing:
Works like a charm, thanks a lot !
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
On Wednesday 13 December 2006 15:29, A. M. Archibald wrote:
> Generate an axis-permutation tuple and use transpose:
Ah OK. It took me a little while to get it running: instead of
s=list(A.shape)
in your example, one should read
s=range(A.ndim)
But it does the trick, thanks a lot!
And now, dou
On 13/12/06, Pierre GM <[EMAIL PROTECTED]> wrote:
> All,
> I have a ND array whose axes I want to reorganize, so that axis "i" is at the
> end while the others stay in their relative position. What's the easiest ?
Generate an axis-permutation tuple and use transpose:
s = list(A.shape)
s.remove(i)
All,
I have a ND array whose axes I want to reorganize, so that axis "i" is at the
end while the others stay in their relative position. What's the easiest ?
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/l