-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ERR: Improve error message in validate_percentile #51475
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
ERR: Improve error message in validate_percentile #51475
Conversation
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.
This isn't the test we agreed upon.
Please call the message simply msg and you don't need brackets after match=
I apologize for the mistake I made earlier. |
pandas/tests/util/test_validator.py
Outdated
percentile_array = [-0.5, 0.25, 1.5] | ||
msg = "percentiles should all be in the interval \\[0, 1\\]" | ||
with pytest.raises(ValueError, match=msg): | ||
s.quantile(percentile_array) |
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.
There is a file for quantile tests
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.
The pandas/tests/frame/methods/test_quantile.py
one ?
msg = "percentiles should all be in the interval \\[0, 1\\]" | ||
for invalid in [-1, 2, [0.5, -1], [0.5, 2]]: |
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.
Why are you deleting those?
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.
@phofl Do I need append the Series
test ?
Something like :-
msg = "percentiles should all be in the interval \\[0, 1\\]"
for invalid in [-1, 2, [0.5, -1], [0.5, 2]]:
with pytest.raises(ValueError, match=msg):
datetime_series.quantile(invalid)
s = Series(np.random.randn(100))
percentile_array = [-0.5, 0.25, 1.5]
with pytest.raises(ValueError, match=msg):
s.quantile(percentile_array)
@phofl, Is this ok? |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.This PR improves the validation of percentiles in pandas. Previously, when an out-of-range value was detected, the code would suggest a wrong value. This suggestion could be confusing to users and was not always necessary. This PR simplifies the suggestion message to directly state that the value should be between 0 and 1.