diff options
author | Aaron Meurer <asmeurer@gmail.com> | 2021-02-26 18:24:55 -0700 |
---|---|---|
committer | Aaron Meurer <asmeurer@gmail.com> | 2021-02-26 18:24:55 -0700 |
commit | 73d2c1e1675ed9e7fe2bc389ec0079c5c6ce73ee (patch) | |
tree | eec7640db58eec66d33c8d966fb98f136bf60bce /numpy/_array_api | |
parent | b933ebbe1aee58af38f05a341dc3952fc761d777 (diff) | |
download | numpy-73d2c1e1675ed9e7fe2bc389ec0079c5c6ce73ee.tar.gz |
Make the array API constants into dimension 0 arrays
The spec does not actually specify whether these should be dimension 0 arrays
or Python floats (which they are in NumPy). However, making them dimension 0
arrays is cleaner, and ensures they also have all the methods and attributes
that are implemented on the ndarray object.
Diffstat (limited to 'numpy/_array_api')
-rw-r--r-- | numpy/_array_api/_constants.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/numpy/_array_api/_constants.py b/numpy/_array_api/_constants.py index 075b8c3b9..5fde34625 100644 --- a/numpy/_array_api/_constants.py +++ b/numpy/_array_api/_constants.py @@ -1 +1,9 @@ -from .. import e, inf, nan, pi +from ._array_object import ndarray +from ._dtypes import float64 + +import numpy as np + +e = ndarray._new(np.array(np.e, dtype=float64)) +inf = ndarray._new(np.array(np.inf, dtype=float64)) +nan = ndarray._new(np.array(np.nan, dtype=float64)) +pi = ndarray._new(np.array(np.pi, dtype=float64)) |