Skip to content

Fix float->int casting with NaN, inf in check_array #14872

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 6 commits into from
Sep 20, 2019

Conversation

rth
Copy link
Member

@rth rth commented Sep 3, 2019

Closes #14871

Numpy rules when converting float to int convert NaN, inf to np.iinfo(dtype).min/max instead of raising an error. It would be good to address this in numpy somehow numpy/numpy#14412 but meanwhile we can manually apply _assert_all_finite in this case (even with force_all_finite=False)

cc @qinhanmin2014

TODO:

  • fix test_encoders.py tests

@rth rth changed the title Fix float->int casting with NaN, inf in check_array WIP Fix float->int casting with NaN, inf in check_array Sep 3, 2019
@rth rth changed the title WIP Fix float->int casting with NaN, inf in check_array Fix float->int casting with NaN, inf in check_array Sep 3, 2019
Copy link
Member

@qinhanmin2014 qinhanmin2014 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't come up with a better solution, so LGTM.

@qinhanmin2014
Copy link
Member

Please add an entry to the change log at doc/whats_new/v*.rst. Like the other entries there, please reference this pull request with :pr: and credit yourself (and other contributors if applicable) with :user:.

Copy link
Member Author

@rth rth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Guillaume :)

@glemaitre
Copy link
Member

I'll merge when it is green

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

force_all_finite in check_array is broken when dtype="int"
4 participants