diff options
author | Aaron Meurer <asmeurer@gmail.com> | 2021-08-04 20:01:11 -0600 |
---|---|---|
committer | Aaron Meurer <asmeurer@gmail.com> | 2021-08-04 20:01:11 -0600 |
commit | bc20d334b575f897157b1cf3eecda77f3e40e049 (patch) | |
tree | fb5c121332bc8078cd2115cb5a6f023f580afdf4 /numpy/array_api/_array_object.py | |
parent | 5605d687019dc55e594d4e227747c72bebb71a3c (diff) | |
download | numpy-bc20d334b575f897157b1cf3eecda77f3e40e049.tar.gz |
Move the array API dtype categories into the top level
They are not an official part of the spec but are useful for various parts of
the implementation.
Diffstat (limited to 'numpy/array_api/_array_object.py')
-rw-r--r-- | numpy/array_api/_array_object.py | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/numpy/array_api/_array_object.py b/numpy/array_api/_array_object.py index af70058e6..50906642d 100644 --- a/numpy/array_api/_array_object.py +++ b/numpy/array_api/_array_object.py @@ -98,23 +98,14 @@ class Array: if other is NotImplemented: return other """ - from ._dtypes import _result_type - - _dtypes = { - 'all': _all_dtypes, - 'numeric': _numeric_dtypes, - 'integer': _integer_dtypes, - 'integer or boolean': _integer_or_boolean_dtypes, - 'boolean': _boolean_dtypes, - 'floating-point': _floating_dtypes, - } - - if self.dtype not in _dtypes[dtype_category]: + from ._dtypes import _result_type, _dtype_categories + + if self.dtype not in _dtype_categories[dtype_category]: raise TypeError(f'Only {dtype_category} dtypes are allowed in {op}') if isinstance(other, (int, float, bool)): other = self._promote_scalar(other) elif isinstance(other, Array): - if other.dtype not in _dtypes[dtype_category]: + if other.dtype not in _dtype_categories[dtype_category]: raise TypeError(f'Only {dtype_category} dtypes are allowed in {op}') else: return NotImplemented |