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

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

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
sklearn/utils/validation.py Outdated Show resolved Hide resolved
@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

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

sklearn/utils/tests/test_validation.py Outdated Show resolved Hide resolved
sklearn/utils/tests/test_validation.py Outdated Show resolved Hide resolved
@qinhanmin2014
Copy link
Member

@qinhanmin2014 qinhanmin2014 commented Sep 5, 2019

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:.

@glemaitre glemaitre added this to REVIEWED AND WAITING FOR CHANGES in Guillaume's pet Sep 17, 2019
Copy link
Member Author

@rth rth left a comment

Thanks Guillaume :)

doc/whats_new/v0.22.rst Outdated Show resolved Hide resolved
doc/whats_new/v0.22.rst Outdated Show resolved Hide resolved
@glemaitre
Copy link
Contributor

@glemaitre glemaitre commented Sep 20, 2019

I'll merge when it is green

@glemaitre glemaitre moved this from REVIEWED AND WAITING FOR CHANGES to TO BE MERGED in Guillaume's pet Sep 20, 2019
@glemaitre glemaitre merged commit e6a4dc9 into scikit-learn:master Sep 20, 2019
19 checks passed
@glemaitre glemaitre moved this from TO BE MERGED to MERGED in Guillaume's pet Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

4 participants