From 26b801a435f2b0d813a37910047062f0f7dadc89 Mon Sep 17 00:00:00 2001 From: crusaderky Date: Thu, 3 Apr 2025 09:39:24 +0100 Subject: [PATCH] `__setitem__` type promotion rules for array values --- src/array_api_stubs/_draft/array_object.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/array_api_stubs/_draft/array_object.py b/src/array_api_stubs/_draft/array_object.py index 08d5c0b6e..102bb3282 100644 --- a/src/array_api_stubs/_draft/array_object.py +++ b/src/array_api_stubs/_draft/array_object.py @@ -1134,8 +1134,10 @@ def __setitem__( Indexing semantics when ``key`` is an integer array or a tuple of integers and integer arrays is currently unspecified and thus implementation-defined. This will be revisited in a future revision of this standard. - Setting array values must not affect the data type of ``self``. - - When ``value`` is a Python scalar (i.e., ``int``, ``float``, ``complex``, ``bool``), behavior must follow specification guidance on mixing arrays with Python scalars (see :ref:`type-promotion`). - - When ``value`` is an ``array`` of a different data type than ``self``, how values are cast to the data type of ``self`` is implementation defined. + - ``value`` must be promoted to ``self.dtype`` according to :ref:`type-promotion`; if this is not possible, behavior is undefined. + + .. versionchanged:: 2025.12 + Specified :ref:`type-promotion` when ``value`` is an array. """ def __sub__(self: array, other: Union[int, float, complex, array], /) -> array: