Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: Ensure that same-kind casting works for uints (mostly) #27802

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

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

seberg
Copy link
Member

@seberg seberg commented Nov 20, 2024

This is the most minimal fix I could think off... If we have uints still use the out-of-bounds value, but make it uint. This is because the code uses copyto with the default same-kind casting in places...

This doesn't remove all the other quirks, and surely, it is a behavior change in some awkward situations (since you got a uint, someone might mix the newly uint value with an integer and get float64 results, etc.)

But... it is by far the most minimal fix I could think of after a longer time.

A more thorough fix may be to just always store the exact dtype, but it would propagate differently e.g. when casting. A start for this is currently in gh-27596.

Closes gh-27269, gh-27580


I am not convinced we should backport this or not. It is the most minimal fix I could think of (besides adding unsafe casts everywhere and hoping for the best/that we found them all). But it clearly has the potential to change behavior in some contexts...

This is the most minimal fix I could think off... If we have uints
still use the out-of-bounds value, but make it uint.  This is because
the code uses copyto with the default same-kind casting in places...

This doesn't remove all the other quirks, and surely, it is a behavior
change in some awkward situations (since you got a uint, someone might
mix the newly uint value with an integer and get float64 results, etc.)

But... it is by far the most minimal fix I could think of after a longer
time.

A more thorough fix may be to just always store the exact dtype, but
it would propagate differently e.g. when casting.  A start for this
is currently in numpygh-27596.

Closes numpygh-27269, numpygh-27580
@charris charris merged commit 13d8c5d into numpy:main Nov 20, 2024
69 checks passed
@charris
Copy link
Member

charris commented Nov 20, 2024

Thanks Sebastian.

@seberg seberg deleted the issue-27269-27580 branch November 20, 2024 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: filled MaskedArray becomes object dtype if given a fill_value of None
2 participants