From 103a8fbd437170a579cedaa844c30db6e1c38ce8 Mon Sep 17 00:00:00 2001 From: Stephannie Jimenez Date: Wed, 15 Dec 2021 12:22:18 -0500 Subject: [PATCH 1/2] Transform constants.md to rst format --- spec/API_specification/constants.md | 39 ------------------- spec/API_specification/constants.rst | 24 ++++++++++++ .../API_specification/signatures/constants.py | 25 ++++++++++++ 3 files changed, 49 insertions(+), 39 deletions(-) delete mode 100644 spec/API_specification/constants.md create mode 100644 spec/API_specification/constants.rst create mode 100644 spec/API_specification/signatures/constants.py diff --git a/spec/API_specification/constants.md b/spec/API_specification/constants.md deleted file mode 100644 index 78cdc8de7..000000000 --- a/spec/API_specification/constants.md +++ /dev/null @@ -1,39 +0,0 @@ -# Constants - -> Array API specification for constants. - -A conforming implementation of the array API standard must provide and support the following constants adhering to the following conventions. - -- Each constant must have a Python floating-point data type (i.e., `float`) and be provided as a Python scalar value. - - - -## Objects in API - -(constant-e)= -### e - -IEEE 754 floating-point representation of Euler's constant. - -```text -e = 2.71828182845904523536028747135266249775724709369995... -``` - -(constant-inf)= -### inf - -IEEE 754 floating-point representation of (positive) infinity. - -(constant-nan)= -### nan - -IEEE 754 floating-point representation of Not a Number (`NaN`). - -(constant-pi)= -### pi - -IEEE 754 floating-point representation of the mathematical constant `π`. - -```text -pi = 3.1415926535897932384626433... -``` diff --git a/spec/API_specification/constants.rst b/spec/API_specification/constants.rst new file mode 100644 index 000000000..eab159c9d --- /dev/null +++ b/spec/API_specification/constants.rst @@ -0,0 +1,24 @@ +Constants +========= + + Array API specification for constants. + +A conforming implementation of the array API standard must provide and support the following constants adhering to the following conventions. + +- Each constant must have a Python floating-point data type (i.e., ``float``) and be provided as a Python scalar value. + +Objects in API +-------------- + +.. currentmodule:: signatures.constants + +.. + NOTE: please keep the functions in alphabetical order + +.. autosummary:: + :toctree: generated + + e + inf + nan + pi diff --git a/spec/API_specification/signatures/constants.py b/spec/API_specification/signatures/constants.py new file mode 100644 index 000000000..069f10005 --- /dev/null +++ b/spec/API_specification/signatures/constants.py @@ -0,0 +1,25 @@ +e = None +""" +IEEE 754 floating-point representation of Euler's constant. + +``e = 2.71828182845904523536028747135266249775724709369995...`` +""" + +inf = None +""" +IEEE 754 floating-point representation of (positive) infinity. +""" + +nan = None +""" +IEEE 754 floating-point representation of Not a Number (``NaN``). +""" + +pi = None +""" +IEEE 754 floating-point representation of the mathematical constant ``π``. + +``pi = 3.1415926535897932384626433...`` +""" + +__all__ = ['e', 'inf', 'nan', 'pi'] From 69f453cd3ba51b817072225206f58421e5085631 Mon Sep 17 00:00:00 2001 From: Stephannie Jimenez Date: Mon, 10 Jan 2022 12:37:31 -0500 Subject: [PATCH 2/2] Add the constants as floats --- spec/API_specification/signatures/constants.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/API_specification/signatures/constants.py b/spec/API_specification/signatures/constants.py index 069f10005..813b6d079 100644 --- a/spec/API_specification/signatures/constants.py +++ b/spec/API_specification/signatures/constants.py @@ -1,21 +1,21 @@ -e = None +e = 2.718281828459045 """ IEEE 754 floating-point representation of Euler's constant. ``e = 2.71828182845904523536028747135266249775724709369995...`` """ -inf = None +inf = float('inf') """ IEEE 754 floating-point representation of (positive) infinity. """ -nan = None +nan = float('nan') """ IEEE 754 floating-point representation of Not a Number (``NaN``). """ -pi = None +pi = 3.141592653589793 """ IEEE 754 floating-point representation of the mathematical constant ``π``.