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

Error with floats(max_value=<one less than inf>, allow_infinity=False, exclude_max=True) could be more helpful #3207

Closed
gjoseph92 opened this issue Jan 6, 2022 · 0 comments · Fixed by #3250
Labels
legibility make errors helpful and Hypothesis grokable

Comments

@gjoseph92
Copy link

This has already been mentioned in #1859 (comment), but I couldn't find a standalone issue for it.

The error allow_infinity=False excludes min_value=inf (added in #1860 I believe) is a bit confusing to see when you are certain you didn't pass max_value=inf. It took me far longer than I'd like to realize that the highest-possible finite float was getting passed in as max_value, leaving no room for a larger value besides infinity. If worded differently, this might have saved me some time.

I assume this is happening because the min_value gets next_up'd in:

if min_value is not None and (
exclude_min or (min_arg is not None and min_value < min_arg)
):
min_value = next_up_normal(min_value, width, assumed_allow_subnormal)

so when the check actually happens, it appears the user has passed in inf.

Even a message like allow_infinity=False exclude_max=True excludes min_value={sys.float_info.max} would have made the problem much clearer, though I think it could be worded in a more friendly way for users who are less familiar with how floats work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legibility make errors helpful and Hypothesis grokable
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants