-
Notifications
You must be signed in to change notification settings - Fork 59
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
Move to numpy 2.0 #42
Comments
We need to address this at some point. For now, we should make sure that we have regression tests that run all algorithms with settings that make them deterministic and check for exact result values. This should hopefully make us bulletproof against accidentally changing the output by updating a dependency. |
What errors do you get with numpy>=2 ? I was surprised to see my numpy being downgraded during a poetry install :D. |
Hi, we're using Nolds in our project (PyNeuromodulation) and I was wondering what the issue with moving to Numpy 2 is. Nolds is the only package that is downgrading us to Numpy 1.26 right now, which is not a big deal but I was wondering if there's anything I can do to help with the migration here, or what are the tests that are failing right now. |
I have done a bit of digging into the issue and I have pinpointed the problem to the function return np.array([
sigma * (y - x),
rho * x - y - x * z,
x * y - beta * z
], dtype="float32") This is what i get in Numpy 1.26
But in Numpy 2.0
It seems that Numpy 1.26 was either casting the inputs or the results of the intermediate calculations to The floating point error is basically accumulating over the iterations, producing a different result in each version of Numpy. I'm not sure if this is a bug in the |
Nice find! Thank you very much for putting in the work to dig through the code and the numpy changelog. 🙏 👍 I figured it would be something minor like that, since the test results are not far off from the expected value. To safeguard against this, I want to create regression tests in #50. I'll prioritize this issue to double-check that there aren't any other changes introduced with numpy 2.0. I didn't plan to release another version between 0.6.0 and 1.0.0 (see https://github.com/CSchoel/nolds/milestone/1), but if the downgrade to numpy < 2.0 causes issues, I can try to fit in a 0.6.1 that makes nolds fully compatible with numpy 2.0. |
Good news: After implementing the regression tests and checking them for separate versions of numpy and scikit-learn, I can confirm that none of the algorithms behave differently. It's only the code for the Lorenz system itself that seems to be affected - which makes sense, since a chaotic system per definition is sensitive to small changes in its parameters. 😄 I think I should be able to publish version 0.6.1 with relaxed version restrictions without issues. |
Hi @CSchoel, glad that you figured out that the functionality isn't broken between versions of Numpy. Our program doesn't really break by keeping 1.26, but it makes it hard to do some optimizations like calling internal Numpy functions to skip checks (our data is already validated) and save some time during real time data processing, because the internal implementations have changed slightly between versions. Thank you for taking the time to fix this, and have a nice day! |
I just released version 0.6.1 in #59. Please let me know if it works. 😄 |
This is just a note to myself: I've seen some tests for the Lorenz system breaking under numpy >= 2.0. I'll need to investigate what has changed there and make sure we can support newer versions of numpy.
The text was updated successfully, but these errors were encountered: