Skip to content

Commit 12c3aa2

Browse files
committed
Stop testing complex in test_arange
Also ignore very large distances
1 parent a9506a8 commit 12c3aa2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

array_api_tests/test_creation_functions.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ def reals(min_value=None, max_value=None) -> st.SearchStrategy[Union[int, float]
7979
)
8080

8181

82-
@given(dtype=st.none() | hh.numeric_dtypes, data=st.data())
82+
# TODO: support testing complex dtypes
83+
@given(dtype=st.none() | xps.real_dtypes(), data=st.data())
8384
def test_arange(dtype, data):
8485
if dtype is None or dh.is_float_dtype(dtype):
8586
start = data.draw(reals(), label="start")
@@ -128,6 +129,12 @@ def test_arange(dtype, data):
128129
assert m <= _start <= M
129130
assert m <= _stop <= M
130131
assert m <= step <= M
132+
# Ignore ridiculous distances so we don't fail like
133+
#
134+
# >>> torch.arange(9132051521638391890, 0, -91320515216383920)
135+
# RuntimeError: invalid size, possible overflow?
136+
#
137+
assume(abs(_start - _stop) < M // 2)
131138

132139
r = frange(_start, _stop, step)
133140
size = len(r)

0 commit comments

Comments
 (0)