Skip to content

Commit ceb63ea

Browse files
committed
Support int dtypes in test_clip and some portability fixes
1 parent 1b10ebf commit ceb63ea

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

array_api_tests/test_operators_and_elementwise_functions.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ def test_ceil(x):
927927

928928

929929
@pytest.mark.min_version("2023.12")
930-
@given(x=hh.arrays(dtype=hh.real_floating_dtypes, shape=hh.shapes()), data=st.data())
930+
@given(x=hh.arrays(dtype=hh.int_dtypes, shape=hh.shapes()), data=st.data())
931931
def test_clip(x, data):
932932
# TODO: test min/max kwargs, adjust values testing accordingly
933933

@@ -951,7 +951,7 @@ def test_clip(x, data):
951951
), label="max")
952952

953953
# min > max is undefined (but allow nans)
954-
assume(min is None or max is None or not xp.any(xp.asarray(min > max)))
954+
assume(min is None or max is None or not xp.any(xp.asarray(min) > xp.asarray(max)))
955955

956956
kw = data.draw(
957957
hh.specified_kwargs(
@@ -1035,13 +1035,14 @@ def refimpl(_x, _min, _max):
10351035
max_val = max if dh.is_scalar(max) else max[max_idx]
10361036
max_val = stype(max_val)
10371037
expected = refimpl(x_val, min_val, max_val)
1038+
out_val = stype(out[o_idx])
10381039
if math.isnan(expected):
1039-
assert math.isnan(out[o_idx]), (
1040+
assert math.isnan(out_val), (
10401041
f"out[{o_idx}]={out[o_idx]} but should be nan [clip()]\n"
10411042
f"x[{x_idx}]={x_val}, min[{min_idx}]={min_val}, max[{max_idx}]={max_val}"
10421043
)
10431044
else:
1044-
assert out[o_idx] == expected, (
1045+
assert out_val == expected, (
10451046
f"out[{o_idx}]={out[o_idx]} but should be {expected} [clip()]\n"
10461047
f"x[{x_idx}]={x_val}, min[{min_idx}]={min_val}, max[{max_idx}]={max_val}"
10471048
)

0 commit comments

Comments
 (0)