Skip to content

Commit

Permalink
also force in the idx case to ensure good shrinks
Browse files Browse the repository at this point in the history
not writing the idx case to the bytestream could result in the idx != 0 case being much bytestream-simpler but not ir-simpler
  • Loading branch information
tybug committed Oct 14, 2024
1 parent 5b3e33e commit 116bbd3
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions hypothesis-python/src/hypothesis/internal/conjecture/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1491,17 +1491,13 @@ def draw_integer(
self._cd, forced=None if forced is None else 0, fake_forced=fake_forced
)

return (
self._draw_bounded_integer(
min_value,
max_value,
forced=forced,
center=shrink_towards,
fake_forced=fake_forced,
)
if idx == 0
return self._draw_bounded_integer(
min_value,
max_value,
# implicit reliance on dicts being sorted for determinism
else list(weights)[idx - 1]
forced=forced if idx == 0 else list(weights)[idx - 1],
center=shrink_towards,
fake_forced=fake_forced,
)

if min_value is None and max_value is None:
Expand Down

0 comments on commit 116bbd3

Please sign in to comment.