Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

MAINT: Replace np.rollaxis with np.moveaxis #14491

Copy link
Copy link
Closed
@AnirudhDagar

Description

@AnirudhDagar
Issue body actions

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

tupui

Metadata

Metadata

Assignees

No one assigned

    Labels

    maintenanceItems related to regular maintenance tasksItems related to regular maintenance tasks

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.