Skip to content

Commit 930932a

Browse files
committed
Add helper function is_scalar
1 parent bf3b773 commit 930932a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

array_api_tests/dtype_helpers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"is_int_dtype",
3535
"is_float_dtype",
3636
"get_scalar_type",
37+
"is_scalar",
3738
"dtype_ranges",
3839
"default_int",
3940
"default_uint",
@@ -189,6 +190,8 @@ def get_scalar_type(dtype: DataType) -> ScalarType:
189190
else:
190191
return bool
191192

193+
def is_scalar(x):
194+
return isinstance(x, (int, float, complex, bool))
192195

193196
def _make_dtype_mapping_from_names(mapping: Dict[str, Any]) -> EqualityMapping:
194197
dtype_value_pairs = []

0 commit comments

Comments
 (0)