From 73d2c1e1675ed9e7fe2bc389ec0079c5c6ce73ee Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Fri, 26 Feb 2021 18:24:55 -0700 Subject: 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. --- numpy/_array_api/_constants.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'numpy/_array_api') 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)) -- cgit v1.2.1