From d9b958259bda8db50949922770101217b2d0b50a Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Fri, 16 Jul 2021 15:02:10 -0600 Subject: Move the dtype check to the array API Array._new constructor --- numpy/_array_api/_array_object.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'numpy/_array_api/_array_object.py') diff --git a/numpy/_array_api/_array_object.py b/numpy/_array_api/_array_object.py index 0659b7b05..267bd698f 100644 --- a/numpy/_array_api/_array_object.py +++ b/numpy/_array_api/_array_object.py @@ -18,7 +18,7 @@ from __future__ import annotations import operator from enum import IntEnum from ._creation_functions import asarray -from ._dtypes import _boolean_dtypes, _integer_dtypes, _floating_dtypes +from ._dtypes import _all_dtypes, _boolean_dtypes, _integer_dtypes, _floating_dtypes from typing import TYPE_CHECKING, Any, Optional, Tuple, Union if TYPE_CHECKING: @@ -61,6 +61,8 @@ class Array: xa = np.empty((), x.dtype) xa[()] = x x = xa + if x.dtype not in _all_dtypes: + raise TypeError(f"The array_api namespace does not support the dtype '{x.dtype}'") obj._array = x return obj -- cgit v1.2.1