Skip to content

Commit 157c16b

Browse files
authored
Restrict linspace support to floating-point data types (#393)
* Restrict support to floating-point data types * Remove linebreak
1 parent 0603fec commit 157c16b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

spec/API_specification/signatures/creation_functions.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,20 @@ 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. 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``.
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``.
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+
2531
Returns
2632
-------
2733
out: array

0 commit comments

Comments
 (0)