Skip to content

Commit 6b6870e

Browse files
authored
Refactor number type checks using _NUMBERS tuple
1 parent 0c4c025 commit 6b6870e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎mpython/core/base_types.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from ..utils import _is_matlab_object, _matlab_array_types, DelayedImport
66

7+
_NUMBERS = (np.number, np.bool_, int, float, complex, bool)
8+
79

810
class _imports(DelayedImport):
911
Array = 'mpython.array.Array'
@@ -108,8 +110,7 @@ def from_any(cls, other, **kwargs):
108110
else:
109111
return Cell.from_any(other)
110112

111-
if isinstance(other, (np.ndarray, np.number, np.bool_,
112-
int, float, complex, bool)):
113+
if isinstance(other, (np.ndarray, *_NUMBERS)):
113114
# [array of] numbers -> Array
114115
if _runtime:
115116
return Array._from_runtime(other, _runtime)

0 commit comments

Comments
 (0)