-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Fix: RuntimeWarning by dividing by zero in test_radius_neighbors_classifier_zero_distance #19395
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: RuntimeWarning by dividing by zero in test_radius_neighbors_classifier_zero_distance #19395
Conversation
…s_classifier_zero_distance
Hi again, Similarly to suggestions in #19396, could you add a test to assert that the warning is not thrown? |
Thanks for your review! |
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.
LGTM. Thanks @nuka137!
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.
thanks @nuka137, a few comments.
Thanks @jeremiedbb , @glemaitre . |
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.
LGTM, thanks @nuka137
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.
I am fine with this fix. Let's just document why we expect a warning here.
Linter is green, merged! Thanks again @ nuka137 for your bearing with us :) |
Reference Issues/PRs
#19334
What does this implement/fix? Explain your changes.
The runtime error is caused by
_weight_func
function which will be passed toneighbors.RadiusNeighborsClassifier
.The
dist
value becomes zero in this test, and this makes the returned valueinf
.So, I added small value
1e-8
to denominator to avoid small value division.