Skip to content

Fix way to determine default_complex #283

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 4 commits into from
Aug 23, 2024
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
2 changes: 1 addition & 1 deletion array_api_tests/dtype_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def accumulation_result_dtype(x_dtype, dtype_kwarg):
default_float = xp.asarray(float()).dtype
if default_float not in real_float_dtypes:
warn(f"inferred default float is {default_float!r}, which is not a float")
if api_version > "2021.12":
Copy link
Member

Choose a reason for hiding this comment

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

I don't know about removing this. This is the check that's currently done throughout the suite to check for complex support.

Maybe we should instead make sure that ARRAY_API_TESTS_SKIP_DTYPES works correctly for complex dtypes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I readded the version check and added a check that no complex types are requested to be skipped.

if api_version > "2021.12" and ({'complex64', 'complex128'} - set(skip_dtypes)):
default_complex = xp.asarray(complex()).dtype
if default_complex not in complex_dtypes:
warn(
Expand Down
4 changes: 2 additions & 2 deletions array_api_tests/hypothesis_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,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 = sampled_from(dh.complex_dtypes)
complex_dtypes: SearchStrategy[Any] | None = sampled_from(dh.complex_dtypes) if dh.complex_dtypes else None

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

Expand Down
Loading