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 2.0 compatibility #1420

Merged
merged 3 commits into from
Jun 26, 2024
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
12 changes: 6 additions & 6 deletions pypesto/history/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(
trace = pd.read_csv(self.file, header=[0, 1], index_col=0)
# replace 'nan' in cols with np.NAN
cols = pd.DataFrame(trace.columns.to_list())
cols[cols == "nan"] = np.NaN
cols[cols == "nan"] = np.nan
trace.columns = pd.MultiIndex.from_tuples(
cols.to_records(index=False).tolist()
)
Expand All @@ -78,11 +78,11 @@ def __init__(
self._update_counts_from_trace()

def _update_counts_from_trace(self) -> None:
self._n_fval = self._trace[(N_FVAL, np.NaN)].max()
self._n_grad = self._trace[(N_GRAD, np.NaN)].max()
self._n_hess = self._trace[(N_HESS, np.NaN)].max()
self._n_res = self._trace[(N_RES, np.NaN)].max()
self._n_sres = self._trace[(N_SRES, np.NaN)].max()
self._n_fval = self._trace[(N_FVAL, np.nan)].max()
self._n_grad = self._trace[(N_GRAD, np.nan)].max()
self._n_hess = self._trace[(N_HESS, np.nan)].max()
self._n_res = self._trace[(N_RES, np.nan)].max()
self._n_sres = self._trace[(N_SRES, np.nan)].max()

def update(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypesto/visualize/optimizer_convergence.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def optimizer_convergence(
2,
)
if grad is not None
else np.NaN
else np.nan
)
for grad in result.optimize_result.grad
]
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ keywords =

[options]
install_requires =
numpy >= 1.19.1, != 1.24.0
numpy >= 1.19.1, != 1.24.0, < 2.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think either requiring <2.0 or >=2.0 will be a pain to users, so I'd avoid that here.

The current issue with nlopt can be solved by installing numpy<2.0 specifically in the respective tox env. (Consider opening an nlopt issue regarding numpy2.0 support if there isn't any yet.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Changed it accordingly for now.

scipy >= 1.5.2
pandas >= 1.5.0
cloudpickle >= 1.5.0
Expand Down
Loading