[Numpy-discussion] numpy.rot90 bug with >2D arrays

Zachary Pincus zpincus@stanford....
Wed Sep 5 15:10:38 CDT 2007


Hello,

numpy.rot90 (from twodim_base.by) says it works only on the first two  
axes of an array, but due to its use of the transpose method (which  
reverses the shape tuple), can affect other axes.

For example:
a = numpy.ones((50,40,3))
b = numpy.rot90(a)
assert(b.shape == (3,40,50))
# desired result is b.shape == (40,50,3)

I believe that the fix is to replace the two calls to 'transpose()'  
in the function with 'swapaxes(0,1)'. This would allow rotating an  
array along just the first two axes.

Does this fix look right? Should I file a bug or can someone just  
check that in?

Zach



More information about the Numpy-discussion mailing list