-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Avoid unsafe casts from float to unsigned int #9964
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
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fefab07
Avoid unsafe casts from float to unsigned int
QuLogic 7813826
Update xarray/coding/variables.py
kmuehlbauer 2e5a93c
Merge branch 'main' into float-uint-casts
kmuehlbauer dabed1d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 22edc3b
Update duck_array_ops.py
kmuehlbauer d82300a
Update duck_array_ops.py
kmuehlbauer d1c7d9b
Merge branch 'main' into float-uint-casts
kmuehlbauer 89a50b6
Update whats-new.rst
kmuehlbauer 63e784e
Update variables.py
kmuehlbauer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
- Loading branch information
commit dabed1da739269afd2791bd7ac43ba8434a5c9a4
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@dcherian @Illviljan Does this agree with your suggestion? This first casts the rounded float to int (of same itemsize) and in a second step the int to the final intN (where N is the wanted itemsize).
@QuLogic Does this work on your machine type?
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.
Yes, this passes tests on all architectures.
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.
@QuLogic Great! Thanks for checking. How should we take it from here? From my perspective, we can drop the changes in
duck_array_ops
and add a code comment why there is the two stage casting. An entry towhats-new.rst
would be good for visibility. Let me know, if you have the bandwidth atm? Otherwise I can take car of this.