matlab's "permute" in python

I'm translating a program from matlab to Python.

The matlab code uses the method permute:

B = PERMUTE(A,ORDER) rearranges the dimensions of A so that they
%   are in the order specified by the vector ORDER.  The array produced
%   has the same values as A but the order of the subscripts needed to 
%   access any particular element are rearranged as specified by ORDER.
%   For an N-D array A, numel(ORDER)>=ndims(A). All the elements of 
%   ORDER must be unique.

Is there an equivalent method in Python/NumPy ?

Answers


This is rolled into the transpose function in numpy.ndarray. The default behavior reverses the order, but you can supply a list of your own order.


Need Your Help

How to set up Automapper in ASP.NET Core

c# asp.net-core automapper

I'm relatively new at .NET, and I decided to tackle .NET Core instead of learning the "old ways". I found a detailed article about setting up AutoMapper for .NET Core here, but is there a more simple

Convert vim / search to search and replace without retyping regular expression

regex vim vi replace

When I perform a search and replace in Vim, I like to use the search function (/regex) first to visually test my regex.