From c1cdabf4709eaae2d80fca3dfce9318021647111 Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Fri, 28 Mar 2025 10:20:07 +0100 Subject: [PATCH 1/4] DOC: clarify that nested asarray is unspecified --- src/array_api_stubs/_draft/creation_functions.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/array_api_stubs/_draft/creation_functions.py b/src/array_api_stubs/_draft/creation_functions.py index c09800783..8ebdc4e62 100644 --- a/src/array_api_stubs/_draft/creation_functions.py +++ b/src/array_api_stubs/_draft/creation_functions.py @@ -90,6 +90,10 @@ def asarray( An object supporting the buffer protocol can be turned into a memoryview through ``memoryview(obj)``. + .. note:: + If ``obj`` is a sequence with some elements being arrays, the behavior is unspecified and thus implementation-defined. Conforming + implentations may perform the conversion or raise an error. + dtype: Optional[dtype] output array data type. If ``dtype`` is ``None``, the output array data type must be inferred from the data type(s) in ``obj``. If all input values are Python scalars, then, in order of precedence, From b11fd84ffb50c81163deef19c5459241b02bd9a1 Mon Sep 17 00:00:00 2001 From: Lucas Colley Date: Sun, 11 May 2025 08:55:44 +0100 Subject: [PATCH 2/4] Update src/array_api_stubs/_draft/creation_functions.py --- src/array_api_stubs/_draft/creation_functions.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/array_api_stubs/_draft/creation_functions.py b/src/array_api_stubs/_draft/creation_functions.py index 8ebdc4e62..2f779dc84 100644 --- a/src/array_api_stubs/_draft/creation_functions.py +++ b/src/array_api_stubs/_draft/creation_functions.py @@ -94,6 +94,8 @@ def asarray( If ``obj`` is a sequence with some elements being arrays, the behavior is unspecified and thus implementation-defined. Conforming implentations may perform the conversion or raise an error. + To join a sequence of arrays along a new axis, see :func:`~array_api.stack`. + dtype: Optional[dtype] output array data type. If ``dtype`` is ``None``, the output array data type must be inferred from the data type(s) in ``obj``. If all input values are Python scalars, then, in order of precedence, From d23ec229dc0d7fb8724b4845eabaa2a04b746f3a Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 26 May 2025 00:25:31 -0700 Subject: [PATCH 3/4] docs: move notes to notes section --- .../_draft/creation_functions.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/array_api_stubs/_draft/creation_functions.py b/src/array_api_stubs/_draft/creation_functions.py index 2f779dc84..e606fb921 100644 --- a/src/array_api_stubs/_draft/creation_functions.py +++ b/src/array_api_stubs/_draft/creation_functions.py @@ -90,12 +90,6 @@ def asarray( An object supporting the buffer protocol can be turned into a memoryview through ``memoryview(obj)``. - .. note:: - If ``obj`` is a sequence with some elements being arrays, the behavior is unspecified and thus implementation-defined. Conforming - implentations may perform the conversion or raise an error. - - To join a sequence of arrays along a new axis, see :func:`~array_api.stack`. - dtype: Optional[dtype] output array data type. If ``dtype`` is ``None``, the output array data type must be inferred from the data type(s) in ``obj``. If all input values are Python scalars, then, in order of precedence, @@ -106,14 +100,6 @@ def asarray( Default: ``None``. - .. admonition:: Note - :class: note - - 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:`array_api.astype`. - - .. note:: - If an input value exceeds the precision of the resolved output array data type, behavior is left unspecified and, thus, implementation-defined. - device: Optional[device] device on which to place the created array. If ``device`` is ``None`` and ``obj`` is an array, the output array device must be inferred from ``obj``. Default: ``None``. copy: Optional[bool] @@ -127,6 +113,10 @@ def asarray( Notes ----- + - If ``obj`` is a sequence with some elements being arrays, behavior is unspecified and thus implementation-defined. Conforming implementations may perform a conversion or raise an exception. To join a sequence of arrays along a new axis, see :func:`~array_api.stack`. + - 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:`array_api.astype`. + - If an input value exceeds the precision of the resolved output array data type, behavior is left unspecified and, thus, implementation-defined. + .. versionchanged:: 2022.12 Added complex data type support. """ From 3843466e75649c604dee8d5b959dd40215416c24 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 26 May 2025 00:26:34 -0700 Subject: [PATCH 4/4] docs: use consistent phrasing --- src/array_api_stubs/_draft/creation_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/array_api_stubs/_draft/creation_functions.py b/src/array_api_stubs/_draft/creation_functions.py index e606fb921..523abee64 100644 --- a/src/array_api_stubs/_draft/creation_functions.py +++ b/src/array_api_stubs/_draft/creation_functions.py @@ -115,7 +115,7 @@ def asarray( - If ``obj`` is a sequence with some elements being arrays, behavior is unspecified and thus implementation-defined. Conforming implementations may perform a conversion or raise an exception. To join a sequence of arrays along a new axis, see :func:`~array_api.stack`. - 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:`array_api.astype`. - - If an input value exceeds the precision of the resolved output array data type, behavior is left unspecified and, thus, implementation-defined. + - If an input value exceeds the precision of the resolved output array data type, behavior is unspecified and thus implementation-defined. .. versionchanged:: 2022.12 Added complex data type support.