[Numpy-discussion] Re: ndarray shape permutation

2022-05-18 Thread Paul Korir
Thank you very much for your replies. xarray is perfect though I'm not sure what overhead I'm paying to get the following: import numpy as np import xarray as xr data = xr.DataArray(np.random.randn(2, 3, 4), dims=("x", "y", "z")) data.transpose('z', 'y', 'x').shape data.transpose('y', 'z', 'x').s

[Numpy-discussion] Re: ndarray shape permutation

2022-05-17 Thread Paul Korir
Thanks for your replies. In retrospect, I realise that using the shape will not be helpful for a cubic array i.e. the permutations of (10, 10, 10) are all (10, 10, 10)! However, the problem remains. Let me try to explain. Short version The problem boils down to the meaning of axis indices as a

[Numpy-discussion] ndarray shape permutation

2022-05-17 Thread Paul Korir
Hellos, I would like to propose `numpy.ndarray.permute_shape()` method to predictably permute the shape of an ndarray. In my opinion, the current alternatives (`swapaxes`, `transform`, `moveaxes` and friends) are counterintuitive and rely on referring to the axis indices. It would be abundantly