Skip to content

Raise TypeError on bad dtypes in hh.two_mutual_arrays() #36

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
Nov 17, 2021
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions array_api_tests/hypothesis_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from .array_helpers import ndindex
from .function_stubs import elementwise_functions
from .pytest_helpers import nargs
from .typing import DataType, Shape
from .typing import DataType, Shape, Array

# Set this to True to not fail tests just because a dtype isn't implemented.
# If no compatible dtype is implemented for a given test, the test will fail
Expand Down Expand Up @@ -344,7 +344,9 @@ def multiaxis_indices(draw, shapes):
def two_mutual_arrays(
dtypes: Sequence[DataType] = dh.all_dtypes,
two_shapes: SearchStrategy[Tuple[Shape, Shape]] = two_mutually_broadcastable_shapes,
) -> SearchStrategy:
) -> Tuple[SearchStrategy[Array], SearchStrategy[Array]]:
if not isinstance(dtypes, Sequence):
raise TypeError(f"{dtypes=} not a sequence")
mutual_dtypes = shared(mutually_promotable_dtypes(dtypes=dtypes))
mutual_shapes = shared(two_shapes)
arrays1 = xps.arrays(
Expand Down
5 changes: 5 additions & 0 deletions array_api_tests/meta/test_hypothesis_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ def test_two_mutual_arrays(x1, x2):
assert broadcast_shapes(x1.shape, x2.shape) in (x1.shape, x2.shape)


def test_two_mutual_arrays_raises_on_bad_dtypes():
with pytest.raises(TypeError):
hh.two_mutual_arrays(dtypes=xps.scalar_dtypes())


def test_kwargs():
results = []

Expand Down