ejeschke / ginga

The Ginga astronomical FITS file viewer
BSD 3-Clause "New" or "Revised" License
120 stars 77 forks source link

TST: Test against numpy 2.0.dev #1054

Closed pllim closed 9 months ago

pllim commented 12 months ago

numpy 2.0.dev is available from their nightly wheel and it has breaking changes. Since the backend here calls a lot of numpy, better make sure they are compatible sooner than later.

pllim commented 11 months ago

https://anaconda.org/scientific-python-nightly-wheels/numpy

pllim commented 10 months ago

While we're at it, since you have release branches, I wonder if you want to pin numpy<2 in those active release branches, so that you don't have to worry about backporting the stuff for this.

ejeschke commented 10 months ago

That makes sense. Also, should we add a numpy 2.0 to our CI? It would be good to have the changes in place for v5.0 if possible.

pllim commented 10 months ago

Might be easier to use tox at this point... Like in astropy

pllim commented 10 months ago

But even before that, you could install numpy 2.0.dev locally and run your test suite and see what breaks... 😬

I suspect there will be some changes needed.

ejeschke commented 10 months ago

How to install astropy with numpy 2.0? When I pip install astropy it uninstalls numpy 2.0 and installs numpy 1.25.2

ejeschke commented 10 months ago

How to install astropy with numpy 2.0? When I pip install astropy it uninstalls numpy 2.0 and installs numpy 1.25.2

I was able to force it, but now astropy fails on numpy 2.0.

pllim commented 10 months ago

You would also have to install astropy dev wheel.

https://docs.astropy.org/en/latest/install.html#installing-pre-built-development-versions-of-astropy

ejeschke commented 10 months ago

It seems the latest astropy is not set up for numpy>=2:

$ python
Python 3.11.5 (main, Sep 11 2023, 13:54:46) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from astropy import __version__; __version__
'6.0.dev94+g51332ce5b'
>>> import astropy.units as u
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/eric/miniconda3/envs/numpy2/lib/python3.11/site-packages/astropy/units/__init__.py", line 23, in <module>
    from .quantity import *
  File "/home/eric/miniconda3/envs/numpy2/lib/python3.11/site-packages/astropy/units/quantity.py", line 36, in <module>
    from .quantity_helper import can_have_arbitrary_unit, check_output, converters_and_unit
  File "/home/eric/miniconda3/envs/numpy2/lib/python3.11/site-packages/astropy/units/quantity_helper/__init__.py", line 16, in <module>
    from . import erfa, function_helpers, helpers, scipy_special
  File "/home/eric/miniconda3/envs/numpy2/lib/python3.11/site-packages/astropy/units/quantity_helper/function_helpers.py", line 81, in <module>
    np.round_,  # Alias for np.round in NUMPY_LT_1_25, but deprecated since.
    ^^^^^^^^^
  File "/home/eric/miniconda3/envs/numpy2/lib/python3.11/site-packages/numpy/__init__.py", line 383, in __getattr__
    raise AttributeError(
AttributeError: `np.round_` was removed in the NumPy 2.0 release. Use `np.round` instead.. Did you mean: 'round'?
pllim commented 10 months ago

That should already be fixed. Do you have latest astropy nightly wheel or dev version from main installed?

ejeschke commented 10 months ago

I installed by:

$ pip install -U -i https://pypi.anaconda.org/astropy/simple astropy --pre

as shown at the top of the document that you linked.

ejeschke commented 10 months ago

It says that should be a "nightly"

ejeschke commented 10 months ago

Installation:

$ pip install -U -i https://pypi.anaconda.org/astropy/simple astropy --pre
Looking in indexes: https://pypi.anaconda.org/astropy/simple
Collecting astropy
  Downloading https://pypi.anaconda.org/astropy/simple/astropy/6.0.dev659%2Bgc095956a9/astropy-6.0.dev659%2Bgc095956a9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9.4/9.4 MB 1.4 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.22 in /home/eric/miniconda3/envs/numpy2/lib/python3.11/site-packages (from astropy) (2.0.0.dev0)
Requirement already satisfied: pyerfa>=2.0 in /home/eric/miniconda3/envs/numpy2/lib/python3.11/site-packages (from astropy) (2.0.0.3)
INFO: pip is looking at multiple versions of astropy to determine which version is compatible with other requirements. This could take a while.
  Downloading https://pypi.anaconda.org/astropy/simple/astropy/6.0.dev653%2Bg40c24589d/astropy-6.0.dev653%2Bg40c24589d-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9.4/9.4 MB 6.2 MB/s eta 0:00:00
  Downloading https://pypi.anaconda.org/astropy/simple/astropy/6.0.dev651%2Bg9353c3ed0/astropy-6.0.dev651%2Bg9353c3ed0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9.4/9.4 MB 9.9 MB/s eta 0:00:00
  Downloading https://pypi.anaconda.org/astropy/simple/astropy/6.0.dev644%2Bgcaaff3e6e/astropy-6.0.dev644%2Bgcaaff3e6e-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9.3/9.3 MB 15.1 MB/s eta 0:00:00
  Downloading https://pypi.anaconda.org/astropy/simple/astropy/6.0.dev631%2Bg0a315634e/astropy-6.0.dev631%2Bg0a315634e-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9.3/9.3 MB 17.8 MB/s eta 0:00:00
  Downloading https://pypi.anaconda.org/astropy/simple/astropy/6.0.dev629%2Bg635f3e0d7/astropy-6.0.dev629%2Bg635f3e0d7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9.3/9.3 MB 23.0 MB/s eta 0:00:00
  Downloading https://pypi.anaconda.org/astropy/simple/astropy/6.0.dev627%2Bg2f0dddaed/astropy-6.0.dev627%2Bg2f0dddaed-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9.3/9.3 MB 24.3 MB/s eta 0:00:00
  Downloading https://pypi.anaconda.org/astropy/simple/astropy/6.0.dev94%2Bg51332ce5b/astropy-6.0.dev94%2Bg51332ce5b-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.2/10.2 MB 26.3 MB/s eta 0:00:00
Requirement already satisfied: PyYAML>=3.13 in /home/eric/miniconda3/envs/numpy2/lib/python3.11/site-packages (from astropy) (6.0.1)
Requirement already satisfied: packaging>=19.0 in /home/eric/miniconda3/envs/numpy2/lib/python3.11/site-packages (from astropy) (23.1)
Installing collected packages: astropy
Successfully installed astropy-6.0.dev94+g51332ce5b
pllim commented 10 months ago

That seems very old. Over at Jdaviz, we're grabbing astropy: 6.0.dev659+gc095956a9 (https://github.com/spacetelescope/jdaviz/actions/runs/6165467948/job/16733310161).

Try build it from source then.

pllim commented 10 months ago

Ah, or try to pip install astropy-iers-data first?

ejeschke commented 10 months ago

6.0.dev659+gc095956a is the first thing it downloaded.

ejeschke commented 10 months ago

Ah, or try to pip install astropy-iers-data first?

That seemed to work!

pllim commented 9 months ago

This issue isn't fully resolved, as we still need to actually add numpy dev to the CI.

ejeschke commented 9 months ago

Sure, no problem.