[Numpy-discussion] .T Transpose shortcut for arrays again

Bill Baxter wbaxter at gmail.com
Tue Jul 4 23:58:45 CDT 2006


Slight correction.

{*} except that negative axes for swapaxes doesn't seem work currently, so
> instead it would need to be something like:
>       a.transpose( a.shape[:-2] + (a.shape[-1],a.shape[-2]) )
>    with a check for "if ndim > 1", of course.
>

Apparently a.swapaxes(-2,-1) does work, and it does exactly what I am
suggesting, including leaving zero-d and 1-d arrays alone.  Not sure why I
thought it wasn't working.

So in short my proposal is to:
--  make a.T a property of array that returns a.swapaxes(-2,-1),
--  make a.H a property of array that returns a.conjugate().swapaxes(-2,-1)
and maybe
--  make a.M a property of array that returns numpy.asmatrix(a)

--Bill
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060705/45405976/attachment.html 


More information about the Numpy-discussion mailing list