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

Raise InvalidArgument with bad shape argument in xps.arrays() #3123

Merged
merged 5 commits into from
Oct 20, 2021

Conversation

honno
Copy link
Member

@honno honno commented Oct 20, 2021

This PR raises an InvalidArgument when shapes in xps.arrays() is not passed as either a valid shape or strategy. This helps avoid confusion when a user might mistakenly pass a strategy-returning function and get an unrelated error (e.g. @asmeurer and I recently).

There are a few odd maintenance things too.

Note: Copying this change to extra.numpy.arrays() is a bit clunky because the NumPy extra implicitly supports general sequences, where I wanted to only support tuples (although to be fair I hadn't instance checked shape as tuples before, but I did pass them blindly to ArrayStrategy). The code that assumes sequences:

@honno honno changed the title Raise InvalidArgument with bad shape argument in `xps.arrays() Raise InvalidArgument with bad shape argument in xps.arrays() Oct 20, 2021
@Zac-HD Zac-HD added the legibility make errors helpful and Hypothesis grokable label Oct 20, 2021
Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - thanks, @honno! We really appreciate your ongoing contributions 🥰

Avoids differing memory reference(?) issues
@honno
Copy link
Member Author

honno commented Oct 20, 2021

I think I know what the issue was with the Win CI, so let's see. (in hindsight, maybe you were already resolving it—sorry!)

@Zac-HD Zac-HD merged commit b66d75f into HypothesisWorks:master Oct 20, 2021
@honno honno deleted the arrays-shape-error branch October 20, 2021 13:28
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 this pull request may close these issues.

2 participants