-
Notifications
You must be signed in to change notification settings - Fork 104
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
MAINT: add support for numpy2 #212
Conversation
patsy/util.py
Outdated
@@ -52,9 +52,21 @@ | |||
"is_categorical_dtype", None) | |||
have_pandas_categorical_dtype = _pandas_is_categorical_dtype is not None | |||
|
|||
if np.lib.NumpyVersion(np.__version__) >= "2.0.0": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this simplified to only the try...except? With some comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have taken the changes to scipy as they are, but I can change them.
However, try-catch is generally considered to be expensive, which is why they use if-elif first in this way, I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you simplify to the try...except for additional robustness then I'll merge this in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1. Let's just do the try/except. Thanks for stepping in here @bashtage !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review!
I simplified it to just a try-except clause and added a comment.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #212 +/- ##
==========================================
- Coverage 98.46% 97.64% -0.83%
==========================================
Files 30 30
Lines 3133 3141 +8
Branches 693 598 -95
==========================================
- Hits 3085 3067 -18
- Misses 25 46 +21
- Partials 23 28 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Sounds like this only affects 2.0.0dev, but not 1.26 or 2.0.0+. Is this right? |
No, as noted in the migration guide, this is a fix for a change in the copy mode in numpy 2.0 (including dev). |
I am a bit skeptical about that. Statsmodels makes heavy use of patsy and runs on NumPy 1.22+ including 2.0.0dev, 2.1 and 2.2. Can you show that patsy fails on a version of NumPy (actual, not just based on the guide)? |
Already reported with logs in issue, #210 Here's the log. The numpy version is 2.1.2.
|
Thanks for updating the patch, @natsukium . Merging it in. |
fixes #210
see more information
https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword
related to scipy/scipy#20172