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

Fix for incompatibility of numpy2.* in the finite difference routines #595

Conversation

ZachMcBreartyUU
Copy link

Numpy changed how np.linalg.solve works, requiring that the second argument is of the from (M,) or (..., M, K) instead of (..., M) or (..., M, K).
Finite difference is using the old form but can be easily updated by adding a axis such that K = 1 and then squeezing (removing) that axis.
The way this is implemented is compatible with numpy1.*
This change is explained in comments in the _coefficients code and is propagated to the rest of the specialized coefficients code without comment.
Solves issues #551
Alternative is to specify that numpy<=1.26.4

…e (M,) or (..., M, K) with corresponding output (..., M) or (..., M, K), so add axis K = 1 then squeeze that axis away.

This change is compatible with numpy 1.*
@Jacob-Stevens-Haas
Copy link
Member

Numpy 2.0 causes a lot of failures, I think limiting to numpy<2.0 would be better for now, unless you're willing to troubleshoot those failures.

@ZachMcBrearty
Copy link

For now I would very much just recommend adding numpy<2.0.0 to the pyproject.toml, esp since numpy 2 will be default installed otherwise.
I didn't realise that numpy2 would clash with cvxpy etc, I only ran pytest on the differentiation file.

@Jacob-Stevens-Haas
Copy link
Member

Jacob-Stevens-Haas commented Feb 1, 2025

@ZachMcBrearty thank you for making this PR nonetheless - it forced me to pay attention to stuff I've been neglecting. Closing in favor of #596, but happy to chat more about this or work towards 2.0 compatibility.

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 this pull request may close these issues.

3 participants