diff options
-rw-r--r-- | numpy/_array_api/_array_object.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/numpy/_array_api/_array_object.py b/numpy/_array_api/_array_object.py index 32a7bc9a8..b78405860 100644 --- a/numpy/_array_api/_array_object.py +++ b/numpy/_array_api/_array_object.py @@ -19,6 +19,8 @@ from enum import IntEnum from ._types import Optional, PyCapsule, Tuple, Union, array from ._creation_functions import asarray +import numpy as np + class ndarray: # Use a custom constructor instead of __init__, as manually initializing # this class is not supported API. @@ -34,6 +36,10 @@ class ndarray: """ obj = super().__new__(cls) + # Note: The spec does not have array scalars, only shape () arrays. + if isinstance(x, np.generic): + # x[...] converts an array scalar to a shape () array. + x = x[...] obj._array = x return obj |