Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpy 1.24 compatibility #1011

Closed
hsinfan1996 opened this issue Dec 20, 2022 · 5 comments · Fixed by #1012
Closed

Numpy 1.24 compatibility #1011

hsinfan1996 opened this issue Dec 20, 2022 · 5 comments · Fixed by #1012
Assignees

Comments

@hsinfan1996
Copy link
Contributor

hsinfan1996 commented Dec 20, 2022

Numpy 1.24.0 removed np.int (need to use python type int instead), which ISiTGR is stilling using.

@hsinfan1996
Copy link
Contributor Author

hsinfan1996 commented Dec 20, 2022

FAST-PT is also affected.

@hsinfan1996 hsinfan1996 changed the title Numpy 1.24 breaks ISiTGR Numpy 1.24 breaks ISiTGR and fast-pt Dec 20, 2022
@hsinfan1996
Copy link
Contributor Author

hsinfan1996 commented Dec 20, 2022

np.bool in pyccl/core.py will make two tests fail.

@nikfilippas
Copy link
Contributor

The warning has been there for a while. Isn't this issue more relevant to the individual libraries though? There's not much we can do to fix it, right?

@hsinfan1996
Copy link
Contributor Author

hsinfan1996 commented Dec 20, 2022

The warning has been there for a while. Isn't this issue more relevant to the individual libraries though? There's not much we can do to fix it, right?

The deprecation expired in Numpy 1.24.0. For CCL, only pyccl/core.py are affected. The two libraries are required for the tests to pass, so it is not a critical issue to users. In case they are not being updated, we can monkey patch it in pyccl/__init__.py with

from packaging.version import parse
import numpy as np
if bool(parse(np.__version__)>=parse('1.24')):
    # for isitgr and fast-pt
    np.int = int
    # the line below is for CCL
    np.bool = bool

@hsinfan1996 hsinfan1996 changed the title Numpy 1.24 breaks ISiTGR and fast-pt Numpy 1.24 compatibility Dec 20, 2022
@nikfilippas
Copy link
Contributor

Okay, I see. I'm happy to review a relevant PR.
As for CCL, I think we can just replace np.integer, np.floating and np.bool in core.py with the built-ins, so we can get rid of the patch as soon as the external libraries are updated.

@hsinfan1996 hsinfan1996 self-assigned this Dec 20, 2022
@hsinfan1996 hsinfan1996 linked a pull request Dec 21, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants