From 621368543020506d2ab41a45c2251103cd65e8ab Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 21 Apr 2022 09:40:39 -0700 Subject: [PATCH 1/4] Fix erroneous updates to arange intended for linspace --- .../signatures/creation_functions.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/spec/API_specification/signatures/creation_functions.py b/spec/API_specification/signatures/creation_functions.py index 7c46aafac..951d26233 100644 --- a/spec/API_specification/signatures/creation_functions.py +++ b/spec/API_specification/signatures/creation_functions.py @@ -14,20 +14,13 @@ def arange(start: Union[int, float], /, stop: Optional[Union[int, float]] = None step: Union[int, float] the distance between two adjacent elements (``out[i+1] - out[i]``). Must not be ``0``; may be negative, this results in an empty array if ``stop >= start``. Default: ``1``. dtype: Optional[dtype] - output array data type. Should be a floating-point data type. If ``dtype`` is ``None``, the output array data type must be the default floating-point data type. Default: ``None``. + output array data type. If ``dtype`` is ``None``, the output array data type must be inferred from ``start``, ``stop`` and ``step``. If those are all integers, the output array dtype must be the default integer dtype; if one or more have type ``float``, then the output array dtype must be the default floating-point data type. Default: ``None``. device: Optional[device] device on which to place the created array. Default: ``None``. - .. note:: This function cannot guarantee that the interval does not include the ``stop`` value in those cases where ``step`` is not an integer and floating-point rounding errors affect the length of the output array. - .. note:: - While this specification recommends that this function only return arrays having a floating-point data type, specification-compliant array libraries may choose to support output arrays having an integer data type (e.g., due to backward compatibility concerns). However, function behavior when generating integer output arrays is unspecified and, thus, is implementation-defined. Accordingly, using this function to generate integer output arrays is not portable. - - .. note:: - As mixed data type promotion is implementation-defined, behavior when ``start`` or ``stop`` exceeds the maximum safe integer of an output floating-point data type is implementation-defined. An implementation may choose to overflow or raise an exception. - Returns ------- out: array @@ -227,7 +220,7 @@ def linspace(start: Union[int, float], stop: Union[int, float], /, num: int, *, num: int number of samples. Must be a non-negative integer value; otherwise, the function must raise an exception. dtype: Optional[dtype] - output array data type. If ``dtype`` is ``None``, the output array data type must be the default floating-point data type. Default: ``None``. + output array data type. Should be a floating-point data type. If ``dtype`` is ``None``, the output array data type must be the default floating-point data type. Default: ``None``. device: Optional[device] device on which to place the created array. Default: ``None``. endpoint: bool @@ -237,6 +230,12 @@ def linspace(start: Union[int, float], stop: Union[int, float], /, num: int, *, ------- out: array a one-dimensional array containing evenly spaced values. + + .. note:: + While this specification recommends that this function only return arrays having a floating-point data type, specification-compliant array libraries may choose to support output arrays having an integer data type (e.g., due to backward compatibility concerns). However, function behavior when generating integer output arrays is unspecified and, thus, is implementation-defined. Accordingly, using this function to generate integer output arrays is not portable. + + .. note:: + As mixed data type promotion is implementation-defined, behavior when ``start`` or ``stop`` exceeds the maximum safe integer of an output floating-point data type is implementation-defined. An implementation may choose to overflow or raise an exception. """ def meshgrid(*arrays: array, indexing: str = 'xy') -> List[array]: From 9535face354d90c717f855d112f744cb6a3b6eb6 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 21 Apr 2022 09:43:57 -0700 Subject: [PATCH 2/4] Add linebreak --- spec/API_specification/signatures/creation_functions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/API_specification/signatures/creation_functions.py b/spec/API_specification/signatures/creation_functions.py index 951d26233..b44bbb768 100644 --- a/spec/API_specification/signatures/creation_functions.py +++ b/spec/API_specification/signatures/creation_functions.py @@ -18,6 +18,7 @@ def arange(start: Union[int, float], /, stop: Optional[Union[int, float]] = None device: Optional[device] device on which to place the created array. Default: ``None``. + .. note:: This function cannot guarantee that the interval does not include the ``stop`` value in those cases where ``step`` is not an integer and floating-point rounding errors affect the length of the output array. From fd637a4579ff8cbac3df84d0f4820f39174b565f Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 21 Apr 2022 09:44:25 -0700 Subject: [PATCH 3/4] Fix indentation --- spec/API_specification/signatures/creation_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/API_specification/signatures/creation_functions.py b/spec/API_specification/signatures/creation_functions.py index b44bbb768..f3231d990 100644 --- a/spec/API_specification/signatures/creation_functions.py +++ b/spec/API_specification/signatures/creation_functions.py @@ -14,7 +14,7 @@ def arange(start: Union[int, float], /, stop: Optional[Union[int, float]] = None step: Union[int, float] the distance between two adjacent elements (``out[i+1] - out[i]``). Must not be ``0``; may be negative, this results in an empty array if ``stop >= start``. Default: ``1``. dtype: Optional[dtype] - output array data type. If ``dtype`` is ``None``, the output array data type must be inferred from ``start``, ``stop`` and ``step``. If those are all integers, the output array dtype must be the default integer dtype; if one or more have type ``float``, then the output array dtype must be the default floating-point data type. Default: ``None``. + output array data type. If ``dtype`` is ``None``, the output array data type must be inferred from ``start``, ``stop`` and ``step``. If those are all integers, the output array dtype must be the default integer dtype; if one or more have type ``float``, then the output array dtype must be the default floating-point data type. Default: ``None``. device: Optional[device] device on which to place the created array. Default: ``None``. From 7491a4949e06aa557a350f2d3deb56e40f5b5c33 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 25 Apr 2022 11:05:22 -0700 Subject: [PATCH 4/4] Add linebreaks Co-authored-by: Matthew Barber --- spec/API_specification/signatures/creation_functions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/API_specification/signatures/creation_functions.py b/spec/API_specification/signatures/creation_functions.py index f3231d990..88db02340 100644 --- a/spec/API_specification/signatures/creation_functions.py +++ b/spec/API_specification/signatures/creation_functions.py @@ -232,6 +232,7 @@ def linspace(start: Union[int, float], stop: Union[int, float], /, num: int, *, out: array a one-dimensional array containing evenly spaced values. + .. note:: While this specification recommends that this function only return arrays having a floating-point data type, specification-compliant array libraries may choose to support output arrays having an integer data type (e.g., due to backward compatibility concerns). However, function behavior when generating integer output arrays is unspecified and, thus, is implementation-defined. Accordingly, using this function to generate integer output arrays is not portable.