Skip to content

Change hh.mutually_broadcastable_shapes() defaults to generate more interesting shapes #75

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
merged 1 commit into from
Jan 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions array_api_tests/hypothesis_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,27 @@ def matrix_shapes(draw, stack_shapes=shapes()):
allow_infinity=False))

def mutually_broadcastable_shapes(
num_shapes: int, **kw
num_shapes: int,
*,
base_shape: Shape = (),
min_dims: int = 0,
max_dims: Optional[int] = None,
min_side: int = 0,
max_side: Optional[int] = None,
) -> SearchStrategy[Tuple[Shape, ...]]:
if max_dims is None:
max_dims = min(max(len(base_shape), min_dims) + 5, 32)
if max_side is None:
max_side = max(base_shape[-max_dims:] + (min_side,)) + 5
return (
xps.mutually_broadcastable_shapes(num_shapes, **kw)
xps.mutually_broadcastable_shapes(
num_shapes,
base_shape=base_shape,
min_dims=min_dims,
max_dims=max_dims,
min_side=min_side,
max_side=max_side,
)
.map(lambda BS: BS.input_shapes)
.filter(lambda shapes: all(
prod(i for i in s if i > 0) < MAX_ARRAY_SIZE for s in shapes
Expand Down