Skip to content

Commit bef0ea3

Browse files
committed
Avoid invalid strategy when sampling from empty sequence
1 parent c0a7bf2 commit bef0ea3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

array_api_tests/hypothesis_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@ def oneway_broadcastable_shapes(draw) -> OnewayBroadcastableShapes:
186186
real_floating_dtypes = sampled_from(dh.real_float_dtypes)
187187
numeric_dtypes = sampled_from(dh.numeric_dtypes)
188188
# Note: this always returns complex dtypes, even if api_version < 2022.12
189-
complex_dtypes = sampled_from(dh.complex_dtypes)
189+
complex_dtypes: SearchStrategy[Any] | None = sampled_from(dh.complex_dtypes) if dh.complex_dtypes else None
190190

191191
def all_floating_dtypes() -> SearchStrategy[DataType]:
192192
strat = floating_dtypes
193-
if api_version >= "2022.12":
193+
if api_version >= "2022.12" and complex_dtypes is not None:
194194
strat |= complex_dtypes
195195
return strat
196196

0 commit comments

Comments
 (0)