From 56345ffb82af39149f7cdf8720089e0ba42e798c Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Fri, 16 Jul 2021 15:02:44 -0600 Subject: Use asarray to convert a scalar into an array in the array API Array constructor --- numpy/_array_api/_array_object.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (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 267bd698f..455e4fb63 100644 --- a/numpy/_array_api/_array_object.py +++ b/numpy/_array_api/_array_object.py @@ -58,9 +58,7 @@ class Array: # Note: The spec does not have array scalars, only 0-D arrays. if isinstance(x, np.generic): # Convert the array scalar to a 0-D array - xa = np.empty((), x.dtype) - xa[()] = x - x = xa + x = np.asarray(x) if x.dtype not in _all_dtypes: raise TypeError(f"The array_api namespace does not support the dtype '{x.dtype}'") obj._array = x -- cgit v1.2.1