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

Add special case shrink pass for sums of integers #2496

Merged
merged 1 commit into from
Jul 29, 2020

Conversation

DRMacIver
Copy link
Member

@DRMacIver DRMacIver commented Jul 19, 2020

We don't currently reduce tests that look like the following well:

@given(st.integers(0, 1000), st.integers(0, 1000))
def test(m, n):
    assert m + n <= 1000

In that we might end up with basically any pair (m, n) with m + n == 1001, when ideally we'd always end up with m = 1, n = 1000.

It'd be nice to normalise such a simple test. This PR adds a special case shrinking pass for tests that have sum lower bounds like this.

Full disclosure: This is me cheating at a benchmark. https://github.com/jlink/shrinking-challenge/blob/main/challenges/bound5.md

@DRMacIver DRMacIver merged commit 90232a8 into master Jul 29, 2020
@DRMacIver DRMacIver deleted the DRMacIver/goodhart branch July 29, 2020 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants