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 #1012

Merged
merged 7 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pyccl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
# SWIG-generated
from . import ccllib as lib

# monkey patch for isitgr and fast-pt if Numpy>=1.24
from packaging.version import parse
import numpy as np
nikfilippas marked this conversation as resolved.
Show resolved Hide resolved
if parse(np.__version__) >= parse('1.24'):
np.int = int
del parse
del np

# Errors
from .errors import (
CCLError,
Expand Down
6 changes: 3 additions & 3 deletions pyccl/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,11 @@ def write_yaml(self, filename):
"""
def make_yaml_friendly(d):
for k, v in d.items():
if isinstance(v, np.floating):
if isinstance(v, float):
d[k] = float(v)
elif isinstance(v, np.integer):
elif isinstance(v, int):
d[k] = int(v)
elif isinstance(v, np.bool):
elif isinstance(v, bool):
d[k] = bool(v)
elif isinstance(v, dict):
make_yaml_friendly(v)
Expand Down