astropy icon indicating copy to clipboard operation
astropy copied to clipboard

Replace `np.rollaxis()` with `np.moveaxis()` but it is not drop-in replacement

Open eerovaher opened this issue 2 years ago • 10 comments

NumPy documentation recommends using np.moveaxis() instead of np.rollaxis(). Currently astropy uses np.rollaxis() more than np.moveaxis(), but there is no reason we should not follow NumPy's recommendation. The lines of code that call np.rollaxis() can be found with git grep 'rollaxis('. The following sub-packages need to be updated:

  • [ ] modeling – some work completed, but needs review
  • [ ] stats – #15727
  • [ ] time – #15727

Pull requests can replace np.rollaxis() with np.moveaxis() in one or more sub-packages.

eerovaher avatar Dec 12 '23 13:12 eerovaher

I would like to work on time.

tanvincible avatar Dec 12 '23 18:12 tanvincible

@TanviPooranmal by all means, feel free to ! Thank you !

neutrinoceros avatar Dec 12 '23 18:12 neutrinoceros

I've addressed the feedback provided in astropy/astropy#15727.

Juan-789 avatar Dec 13 '23 16:12 Juan-789

Maybe need some recommendations how to correctly translate the functions' signatures, as with a variable input to np.rollaxis(arr, axis, start) the effect of a given start is not always straightforward to infer.

dhomeier avatar Dec 13 '23 17:12 dhomeier

Given that in the remaining subpackage to be worked on, modeling, from a quick glance refactoring does not look trivial in at least some cases, I'd rather remove the good-first-issue and package-novice labels now.

dhomeier avatar Dec 13 '23 18:12 dhomeier

We have two PRs now trying to do simple search and replace. I updated the title to explain it is not that easy.

pllim avatar Jan 03 '24 23:01 pllim

Hi ! Is this issue still open to work upon ??

vagish-yadav avatar Jan 14 '24 12:01 vagish-yadav

Hi @vagish-yadav , two subpackages have already been addressed, and some work on modeling has been done, but that one definitely needs further review and debugging. Please note that some of the refactoring for modeling is non-trivial and would best be tackled by someone with a bit of coding experience.

dhomeier avatar Jan 14 '24 22:01 dhomeier

hello guys, can i try to help on this?

NathanMuniz18 avatar Oct 09 '24 10:10 NathanMuniz18

Hi, im new to the project. I could work on the modeling package. Am i allowed to contribute?

FelipeMeiga avatar Jun 03 '25 17:06 FelipeMeiga