Numpy 1.12 significant upgraded features

I find myself needing to rotate 3-D arrays in Python, and with Numpy < 1.12 I end up using awkward constructs like

np.rot90(data.transpose(1,2,0), 2).transpose(2,0,1)

where for example

data.shape==(256,128,128) 

whereas with Numpy >= 1.12, I can simply do

np.rot90(data,2,(1,2))

numpy.flip has also been upgraded to N-dimensional arrays, similarly avoiding the awkward transpose above.

Tags:

Categories:

Updated:

Leave a Comment