-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
REF: Avoid np.can_cast for scalar inference for NEP 50 #55707
Conversation
pandas/core/dtypes/cast.py
Outdated
@@ -699,7 +699,9 @@ def _maybe_promote(dtype: np.dtype, fill_value=np.nan): | |||
dtype = np.dtype(np.object_) | |||
|
|||
elif issubclass(dtype.type, np.integer): | |||
if not np.can_cast(fill_value, dtype): | |||
try: | |||
np_can_hold_element(dtype, fill_value) |
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.
Maybe we should right a wrapper function for this to make our own can cast.
Then, we don't have to scatter try/catch's everywhere.
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.
Good idea. Wrapped in a helper function
Looks like the test failures are timeouts hopefully unrelated to this change. Going to backport this change as this could be useful for 2.1.x |
…ence for NEP 50
Thank you! When do you plan to push out a new dev wheel with this patch? 🙏 |
Wheels uploads run nightly at 3:27 UTC, so hopefully the dev wheels should be available tomorrow |
I can confirm the dev wheel is up and it works now. Thanks again! |
… inference for NEP 50) (#55716) Backport PR #55707: REF: Avoid np.can_cast for scalar inference for NEP 50 Co-authored-by: Matthew Roeschke <[email protected]>
Looks like using
np.can_cast
for scalar casting inference is deprecated. We should probably use our own scalar casting inference routines instead