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

This comment has been minimized.

Copy link
Member

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

@timbicker timbicker mentioned this pull request Sep 8, 2019
4 of 4 tasks complete
@glemaitre glemaitre added this to REVIEWED AND WAITING FOR CHANGES in Guillaume's pet Sep 17, 2019
Copy link
Member Author

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

This comment has been minimized.

Copy link
Contributor

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
19 checks passed
LGTM analysis: C/C++ No code changes detected
Details
LGTM analysis: JavaScript No code changes detected
Details
LGTM analysis: Python No new or fixed alerts
Details
ci/circleci: deploy Your tests passed on CircleCI!
Details
ci/circleci: doc Your tests passed on CircleCI!
Details
ci/circleci: doc artifact Link to 0/doc/_changed.html
Details
ci/circleci: doc-min-dependencies Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
codecov/patch 100% of diff hit (target 96.74%)
Details
codecov/project Absolute coverage decreased by -<.01% but relative coverage increased by +3.25% compared to 746efb5
Details
scikit-learn.scikit-learn Build #20190920.12 succeeded
Details
scikit-learn.scikit-learn (Linux py35_conda_openblas) Linux py35_conda_openblas succeeded
Details
scikit-learn.scikit-learn (Linux py35_ubuntu_atlas) Linux py35_ubuntu_atlas succeeded
Details
scikit-learn.scikit-learn (Linux pylatest_conda_mkl) Linux pylatest_conda_mkl succeeded
Details
scikit-learn.scikit-learn (Linux pylatest_pip_openblas_pandas) Linux pylatest_pip_openblas_pandas succeeded
Details
scikit-learn.scikit-learn (Linux32 py35_ubuntu_atlas_32bit) Linux32 py35_ubuntu_atlas_32bit succeeded
Details
scikit-learn.scikit-learn (Windows py35_pip_openblas_32bit) Windows py35_pip_openblas_32bit succeeded
Details
scikit-learn.scikit-learn (Windows py37_conda_mkl) Windows py37_conda_mkl succeeded
Details
scikit-learn.scikit-learn (macOS pylatest_conda_mkl) macOS pylatest_conda_mkl succeeded
Details
@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
Projects
4 participants
You can’t perform that action at this time.