Description
Context
NumPy initially added np.rollaxis
, but later, several users reported confusing API/working of rollaxis
(see this SO discussion or numpy/numpy#15926 or numpy/numpy#9473). Thus, a more clear and crisp function to achieve the same goal was added i.e named np.moveaxis
.
Quoting @shoyer from the StackOverflow discussion.
NumPy v1.11 and newer includes a new function, moveaxis, that I recommend using instead of rollaxis (disclaimer: I wrote it!). The source axis always ends up at the destination, without any funny off-by-one issues depending on whether start is greater or less than end.
NumPy has already removed any use of rollaxis
internally in favour of moveaxis
with numpy/numpy#9475.
According to rollaxis
documentation:
This function continues to be supported for backward compatibility, but you should prefer moveaxis.
In fact, array/tensor libraries like torch
don't even have rollaxis
, instead, they have the moveaxis
method. (See docs).
Having old functions which are not present in other libraries and are not very user friendly make it difficult to read/understand the source code.
Pitch
I propose to replace the use of rollaxis
with moveaxis
in SciPy internally and refactor accordingly, making things a little more coherent. This was added in numpy v1.11.0
, hence it is easy to move away since SciPy claims support for only numpy>=1.16.5
.
I can send a PR if there aren't any issues that I'm missing.
cc @rgommers