Skip to content

Commit ffeb7cb

Browse files
authored
Try except method for assigning default_complex
1 parent 9503db0 commit ffeb7cb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

array_api_tests/dtype_helpers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,12 @@ class MinMax(NamedTuple):
235235
if not hasattr(xp, "asarray"):
236236
default_int = xp.int32
237237
default_float = xp.float32
238-
default_complex = xp.complex64 if api_version > "2021.12" else None
238+
# TODO: when api_version > '2021.12', just assign to xp.complex64,
239+
# otherwise default to None. Need array-api spec to be bumped first (#187).
240+
try:
241+
default_complex = xp.complex64
242+
except AttributeError:
243+
default_complex = None
239244
warn(
240245
"array module does not have attribute asarray. "
241246
"default int is assumed int32, default float is assumed float32"

0 commit comments

Comments
 (0)