-
Notifications
You must be signed in to change notification settings - Fork 628
Open
Labels
bugsomething is clearly wrong heresomething is clearly wrong here
Description
Simple example, here is unbounded case:
>>> import hypothesis.strategies as st
>>> n = 5000
... ints = st.integers()
... cnt = 0
... for _ in range(n):
... if ints.example() < 0:
... cnt += 1
... print(f"{cnt/n:.0%}")
...
46%Here is a small interval (bound are symmetrical):
>>> bits = 16
... mval = (1<<bits) - 1
... ints = st.integers(min_value=-mval, max_value=mval)
... cnt = 0
... for _ in range(n):
... if ints.example() < 0:
... cnt += 1
... print(f"{cnt/n:.0%}")
...
46%But what happens with bigger bounds?
Distribution looks asymmetrical:
>>> bits = 32
... mval = (1<<bits) - 1
... ints = st.integers(min_value=-mval, max_value=mval)
... cnt = 0
... for _ in range(n):
... if ints.example() < 0:
... cnt += 1
... print(f"{cnt/n:.0%}")
...
79%
>>> bits = 64
... mval = (1<<bits) - 1
... ints = st.integers(min_value=-mval, max_value=mval)
... cnt = 0
... for _ in range(n):
... if ints.example() < 0:
... cnt += 1
... print(f"{cnt/n:.0%}")
...
81%I'm giving examples with, huh, examples(), but same happens for regular tests with pytest&hypothesis.
Metadata
Metadata
Assignees
Labels
bugsomething is clearly wrong heresomething is clearly wrong here