-
Notifications
You must be signed in to change notification settings - Fork 657
Various typed-choice-sequence shrinking patches #4755
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
Merged
Zac-HD
merged 8 commits into
HypothesisWorks:master
from
Zac-HD:claude/nice-bardeen-xS6yA
May 29, 2026
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0d28c67
Shrink large floats on the float grid
claude dd8b29a
Delete collection elements adaptively when shrinking
claude a19cf7d
Update shrinker internals docs for the choice sequence
claude d2b9b9a
Consolidate release note for shrinker performance
claude 6631e4a
Realign over-long collection draws when shrinking
claude 0a08e95
Shrink large floats via a grid-position bijection
claude 137d036
Test the float-position bijection's invariants
claude 78b2a01
Address review feedback on the overrun-repair branch
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| RELEASE_TYPE: patch | ||
|
|
||
| This patch improves shrinking - the process by which Hypothesis reduces a | ||
| failing example to a minimal one - in two ways. | ||
|
|
||
| First, shrinking large floats (those above ``2**53``) and collections such as | ||
| :func:`~hypothesis.strategies.lists` is now substantially faster, especially for | ||
| large inputs. | ||
|
|
||
| Second, we now shrink tests better when an early choice controls the size of a | ||
| later collection, such as ``n = data.draw(integers()); s = | ||
| data.draw(text(min_size=n, max_size=n))``. Lowering ``n`` would previously | ||
| discard the (interesting) contents of ``s``, leaving the shrinker stuck on a | ||
| larger example than necessary; we now realign by truncating the recorded value. | ||
| This also helps :ref:`stateful tests <stateful>` whose rules draw such | ||
| size-dependent values (:issue:`4006`). | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is correct. The Collection shrinker is terribly named, and is only actually used for shrinking strings and bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree
shrinker.Collectionis badly named! It's generically written to shrink any collection, given an element shrinker. This is the model failing to understand relative terminology.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well among other problems, it's not, it's designed to shrink any sequence.