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

Avoid calling hh.arrays with dtype=None for complex types #313

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 3 additions & 3 deletions array_api_tests/hypothesis_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from hypothesis import assume, reject
from hypothesis.strategies import (SearchStrategy, booleans, composite, floats,
integers, just, lists, none, one_of,
sampled_from, shared, builds)
sampled_from, shared, builds, nothing)

from . import _array_module as xp, api_version
from . import array_helpers as ah
Expand Down Expand Up @@ -200,11 +200,11 @@ def oneway_broadcastable_shapes(draw) -> OnewayBroadcastableShapes:
real_floating_dtypes = sampled_from(dh.real_float_dtypes)
numeric_dtypes = sampled_from(dh.numeric_dtypes)
# Note: this always returns complex dtypes, even if api_version < 2022.12
complex_dtypes: SearchStrategy[Any] | None = sampled_from(dh.complex_dtypes) if dh.complex_dtypes else None
complex_dtypes: SearchStrategy[Any] = sampled_from(dh.complex_dtypes) if dh.complex_dtypes else nothing()

def all_floating_dtypes() -> SearchStrategy[DataType]:
strat = floating_dtypes
if api_version >= "2022.12" and complex_dtypes is not None:
if api_version >= "2022.12" and not complex_dtypes.is_empty:
strat |= complex_dtypes
return strat

Expand Down
3 changes: 3 additions & 0 deletions array_api_tests/test_operators_and_elementwise_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,7 @@ def refimpl(_x, _min, _max):


@pytest.mark.min_version("2022.12")
@pytest.mark.skipif(hh.complex_dtypes.is_empty, reason="no complex data types to draw from")
@given(hh.arrays(dtype=hh.complex_dtypes, shape=hh.shapes()))
def test_conj(x):
out = xp.conj(x)
Expand Down Expand Up @@ -1264,6 +1265,7 @@ def test_hypot(x1, x2):


@pytest.mark.min_version("2022.12")
@pytest.mark.skipif(hh.complex_dtypes.is_empty, reason="no complex data types to draw from")
@given(hh.arrays(dtype=hh.complex_dtypes, shape=hh.shapes()))
def test_imag(x):
out = xp.imag(x)
Expand Down Expand Up @@ -1559,6 +1561,7 @@ def test_pow(ctx, data):


@pytest.mark.min_version("2022.12")
@pytest.mark.skipif(hh.complex_dtypes.is_empty, reason="no complex data types to draw from")
@given(hh.arrays(dtype=hh.complex_dtypes, shape=hh.shapes()))
def test_real(x):
out = xp.real(x)
Expand Down
Loading