-
Notifications
You must be signed in to change notification settings - Fork 906
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 numpy v2 breaking changes #618
base: master
Are you sure you want to change the base?
Conversation
Thanks for this @fjosw. I will try to take a look at some point in the next couple of weeks. |
Hi there, @j-towns! I did see from #620 and I am cognizant of the announcement that |
Hi @agriyakhetarpal, I emailed you with a proposal, have you seen it? |
Hi @j-towns, thanks for sending it out – just responded there. It went to my spam folder, sadly :( I could have responded much earlier otherwise. |
@agriyakhetarpal I emailed you again (11 days ago), did you see that? I have also now emailed @fjosw with a similar proposal. |
Thanks @j-towns, I just sent you a reply. |
Thank you for the ping, @j-towns – just responded! |
I looked a bit into the changes related to the complex sign function today. It is my understanding that the test fails because the numerical approximation of jvp via finite difference does not work when the sign function is defined as However, I think autograd still does the correct thing when the definition of the sign function changes. I verified explicitly that |
The upcoming numpy v2.0.0 release introduces a few breaking changes for autograd. This PR fixes these issues:
msort
was removed from the numpy API. I added conditional imports. The corresponding VJPs are now only defined if the numpy version is <2.np.array(value, copy=False)
was removed. The same effect can now be achieved vianp.asarray(value)
.np.solve
changed.np.linalg.linalg
was renamed tonp.linalg._linalg
.One thing that I did not adress in this PR is the changing behavior for
np.sign
with complex arguments. Instead of the sign of the real part, numpy now returnsz /|z|
.On my machine all tests pass with the latest release versions (numpy==1.26.4 scipy==1.12.0) and the current release candidates (numpy==2.0.0.rc1 scipy==1.13.0rc1) but for
tests/test_systematic.py::test_sign
which fails for numpy v2 withbecause of the aforementioned changes to the behavior of the sign function.