Skip to content

Commit c580517

Browse files
authored
Clarify overflow behavior in asarray (#409)
* Add note concerning overflow in `asarray` * Update notes * Update note
1 parent 93f8d35 commit c580517

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

spec/API_specification/signatures/creation_functions.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ def asarray(obj: Union[array, bool, int, float, NestedSequence, SupportsBufferPr
6262
6363
If ``dtype`` is not ``None``, then array conversions should obey :ref:`type-promotion` rules. Conversions not specified according to :ref:`type-promotion` rules may or may not be permitted by a conforming array library. To perform an explicit cast, use :func:`signatures.data_type_functions.astype`.
6464
65+
.. note::
66+
If an input value exceeds the precision of the resolved output array data type, behavior is left unspecified and, thus, implementation-defined.
67+
6568
device: Optional[device]
6669
device on which to place the created array. If ``device`` is ``None`` and ``x`` is an array, the output array device must be inferred from ``x``. Default: ``None``.
6770
copy: Optional[bool]
@@ -168,7 +171,7 @@ def full(shape: Union[int, Tuple[int, ...]], fill_value: Union[int, float], *, d
168171
output array data type. If ``dtype`` is ``None``, the output array data type must be inferred from ``fill_value``. If the fill value is an ``int``, the output array data type must be the default integer data type. If the fill value is a ``float``, the output array data type must be the default floating-point data type. If the fill value is a ``bool``, the output array must have boolean data type. Default: ``None``.
169172
170173
.. note::
171-
If ``dtype`` is ``None`` and the ``fill_value`` exceeds the precision of the resolved default output array data type, behavior is left unspecified and, thus, implementation-defined.
174+
If the ``fill_value`` exceeds the precision of the resolved default output array data type, behavior is left unspecified and, thus, implementation-defined.
172175
173176
device: Optional[device]
174177
device on which to place the created array. Default: ``None``.
@@ -193,10 +196,10 @@ def full_like(x: array, /, fill_value: Union[int, float], *, dtype: Optional[dty
193196
output array data type. If ``dtype`` is ``None``, the output array data type must be inferred from ``x``. Default: ``None``.
194197
195198
.. note::
196-
If ``dtype`` is ``None`` and the ``fill_value`` exceeds the precision of the resolved output array data type, behavior is unspecified and, thus, implementation-defined.
199+
If the ``fill_value`` exceeds the precision of the resolved output array data type, behavior is unspecified and, thus, implementation-defined.
197200
198201
.. note::
199-
If ``dtype`` is ``None`` and the ``fill_value`` has a data type (``int`` or ``float``) which is not of the same data type kind as the resolved output array data type (see :ref:`type-promotion`), behavior is unspecified and, thus, implementation-defined.
202+
If the ``fill_value`` has a data type (``int`` or ``float``) which is not of the same data type kind as the resolved output array data type (see :ref:`type-promotion`), behavior is unspecified and, thus, implementation-defined.
200203
201204
device: Optional[device]
202205
device on which to place the created array. If ``device`` is ``None``, the output array device must be inferred from ``x``. Default: ``None``.

0 commit comments

Comments
 (0)