__setitem__¶
- array.__setitem__(key: int | slice | ellipsis | Tuple[int | slice | ellipsis, ...] | array, value: int | float | bool | array, /) None¶
Sets
self[key]tovalue.See Indexing for details on supported indexing semantics.
- Parameters:
self (array) – array instance.
key (Union[int, slice, ellipsis, Tuple[Union[int, slice, ellipsis], ...], array]) – index key.
value (Union[int, float, bool, array]) – value(s) to set. Must be compatible with
self[key](see Broadcasting).
Note
Setting array values must not affect the data type of
self.When
valueis a Python scalar (i.e.,int,float,bool), behavior must follow specification guidance on mixing arrays with Python scalars (see Type Promotion Rules).When
valueis anarrayof a different data type thanself, how values are cast to the data type ofselfis implementation defined.