Skip to content

Commit 416b71a

Browse files
kgrytehonno
andauthored
Fix erroneous updates to arange intended for linspace (#421)
* Fix erroneous updates to arange intended for linspace * Add linebreak * Fix indentation * Add linebreaks Co-authored-by: Matthew Barber <[email protected]> Co-authored-by: Matthew Barber <[email protected]>
1 parent c5808f2 commit 416b71a

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

spec/API_specification/signatures/creation_functions.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,14 @@ def arange(start: Union[int, float], /, stop: Optional[Union[int, float]] = None
1414
step: Union[int, float]
1515
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``.
1616
dtype: Optional[dtype]
17-
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``.
17+
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``.
1818
device: Optional[device]
1919
device on which to place the created array. Default: ``None``.
2020
2121
2222
.. note::
2323
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.
2424
25-
.. note::
26-
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.
27-
28-
.. note::
29-
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.
30-
3125
Returns
3226
-------
3327
out: array
@@ -227,7 +221,7 @@ def linspace(start: Union[int, float], stop: Union[int, float], /, num: int, *,
227221
num: int
228222
number of samples. Must be a non-negative integer value; otherwise, the function must raise an exception.
229223
dtype: Optional[dtype]
230-
output array data type. If ``dtype`` is ``None``, the output array data type must be the default floating-point data type. Default: ``None``.
224+
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``.
231225
device: Optional[device]
232226
device on which to place the created array. Default: ``None``.
233227
endpoint: bool
@@ -237,6 +231,13 @@ def linspace(start: Union[int, float], stop: Union[int, float], /, num: int, *,
237231
-------
238232
out: array
239233
a one-dimensional array containing evenly spaced values.
234+
235+
236+
.. note::
237+
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.
238+
239+
.. note::
240+
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.
240241
"""
241242

242243
def meshgrid(*arrays: array, indexing: str = 'xy') -> List[array]:

0 commit comments

Comments
 (0)