Skip to content

Skip asserting to undefined default dtypes in test_sum #163

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 2 commits into from
Jan 11, 2023
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
19 changes: 15 additions & 4 deletions array_api_tests/test_statistical_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,13 @@ def test_prod(x, data):
_dtype = dh.default_float
else:
_dtype = dtype
# We ignore asserting the out dtype if what we expect is undefined
# See https://github.com/data-apis/array-api-tests/issues/106
if not isinstance(_dtype, _UndefinedStub):
if isinstance(_dtype, _UndefinedStub):
# If a default uint cannot exist (i.e. in PyTorch which doesn't support
# uint32 or uint64), we skip testing the output dtype.
# See https://github.com/data-apis/array-api-tests/issues/106
if _dtype in dh.uint_dtypes:
assert dh.is_int_dtype(out.dtype) # sanity check
else:
ph.assert_dtype("prod", x.dtype, out.dtype, _dtype)
_axes = sh.normalise_axis(kw.get("axis", None), x.ndim)
ph.assert_keepdimable_shape(
Expand Down Expand Up @@ -248,7 +252,14 @@ def test_sum(x, data):
_dtype = dh.default_float
else:
_dtype = dtype
ph.assert_dtype("sum", x.dtype, out.dtype, _dtype)
if isinstance(_dtype, _UndefinedStub):
# If a default uint cannot exist (i.e. in PyTorch which doesn't support
# uint32 or uint64), we skip testing the output dtype.
# See https://github.com/data-apis/array-api-tests/issues/160
if _dtype in dh.uint_dtypes:
assert dh.is_int_dtype(out.dtype) # sanity check
else:
ph.assert_dtype("sum", x.dtype, out.dtype, _dtype)
_axes = sh.normalise_axis(kw.get("axis", None), x.ndim)
ph.assert_keepdimable_shape(
"sum", x.shape, out.shape, _axes, kw.get("keepdims", False), **kw
Expand Down