-
Notifications
You must be signed in to change notification settings - Fork 4
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
is_in_bounds
parses majorant incorrectly when bounding range is floats in string form
#140
Comments
is_in_bounds
parse majorant when float in string form is_in_bounds
parses majorant incorrectly when bounding range is floats in string form
I see the problem but my regex-fu is weak. We need a regex that can find int or float. |
The pattern is currently: pattern = (
r"^(?P<lower>[\[\(]?)"
r"(?P<minorant>\d+).*?(?P<majorant>\d+)"
r"(?P<upper>[\]\)]?)$"
) It should be: pattern = (
r"^(?P<lower>[\[\(]?)"
r"(?P<minorant>\d+\.?\d*).*?(?P<majorant>\d+\.?\d*)"
r"(?P<upper>[\]\)]?)$"
) This regex should match a single >>> float("4.")
4.0 |
We should also cover the case where users submit I found pattern = (
r"^(?P<lower>[\[\(]?)"
r"(?P<minorant>[.\d]+).*?(?P<majorant>[.\d]+)"
r"(?P<upper>[\]\)]?)$"
) def test_bad_floats(self) -> None:
with pytest.raises(
ValueError, match="could not convert string to float: '1.1.1.1'"
):
is_in_bounds("(1.1.1.1, 4.0]") |
Of course |
is_in_bounds("[1.0, 4.0]")
should return a majorant of4.0
but instead returns0.0
the number is within the range of 1.0 and 0.0
The text was updated successfully, but these errors were encountered: