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

REF: Avoid np.can_cast for scalar inference for NEP 50 #55707

Merged
merged 5 commits into from
Oct 27, 2023

Conversation

mroeschke
Copy link
Member

Looks like using np.can_cast for scalar casting inference is deprecated. We should probably use our own scalar casting inference routines instead

@mroeschke mroeschke added the Compat pandas objects compatability with Numpy or Python functions label Oct 26, 2023
@@ -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)
Copy link
Member

@lithomas1 lithomas1 Oct 26, 2023

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.

Copy link
Member Author

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

@mroeschke mroeschke added this to the 2.1.3 milestone Oct 27, 2023
@mroeschke
Copy link
Member Author

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

@mroeschke mroeschke merged commit ff5cae7 into pandas-dev:main Oct 27, 2023
31 of 33 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Oct 27, 2023
@mroeschke mroeschke deleted the ref/np/can_cast_avoid branch October 27, 2023 00:58
@pllim
Copy link

pllim commented Oct 27, 2023

Thank you! When do you plan to push out a new dev wheel with this patch? 🙏

@mroeschke
Copy link
Member Author

Wheels uploads run nightly at 3:27 UTC, so hopefully the dev wheels should be available tomorrow

@pllim
Copy link

pllim commented Oct 27, 2023

I can confirm the dev wheel is up and it works now. Thanks again!

mroeschke added a commit that referenced this pull request Oct 27, 2023
… 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants