8000 Include entire range in `check_scalar` error message · Issue #22691 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Include entire range in check_scalar error message #22691

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

Open
thomasjpfan opened this issue Mar 4, 2022 · 3 comments
Open

Include entire range in check_scalar error message #22691

thomasjpfan opened this issue Mar 4, 2022 · 3 comments

Comments

@thomasjpfan
Copy link
Member

Currently docstrings description for scalar ranges uses the interval syntax:

Values must be in the range `[0.0, inf)`.

While the error message uses a different notation:

from sklearn.utils.validation import check_scalar

check_scalar(-1.0, "alpha", target_type=float, min_val=0.0)
# ValueError: alpha == -1.0, must be >= 0.0.

Should we update this notation to be consistent with the docstring? i.e:

# ValueError: alpha == -1.0, must be in the range [0.0, inf)

(I am assuming that inf is always an open boundary)

CC @glemaitre

@Micky774
Copy link
Contributor
Micky774 commented Mar 4, 2022

I'm a fan of this. The consistency is very nice.

@glemaitre
Copy link
Member

I would be fine with this change.

@jeremiedbb
Copy link
Member

I opened #22722 that proposes a common design for parameter validation, to go beyond check_scalar.

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

No branches or pull requests

4 participants
0