Add a better mutually_broadcastable_shapes strategy #73
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.
This is based on the work from
Quansight-Labs/ndindex#126. The strategy that comes
with hypothesis has default parameters that makes it not generate interesting
examples by default. In particular, it will never generate a shape with more
than 2 dimensions and side length more than 3.
This new strategy generates shapes that are based on a base shape drawn from
shapes(), so more complex shapes are possible. This is preferable to doing so
by modifying the parameters to mutually_broadcastable_shapes() because it's
difficult to find parameters that give interesting examples but don't require
too much filtering for total size.
This commit also changes it so that mutually_broadcastable_shapes generates
shapes with minimum side length 0 by default.
For example, before this commit:
After this commit:
The generation with this new strategy is somewhat slower than the old one
(about 2x slower), but the generation speed is not slow enough that it should
matter too much.
The shrinking can also be imperfect with this strategy. For example, I've seen
it shrink to ((0, 1), (0, 2)) for the currently failing in-place tests where
it could shrink to just ((1,), (2,)). I also saw the pre-existing strategy
have the same problem, however. One should just be aware that test failures
involving shapes from this strategy might not actually be shrunk minimally.