Skip to content

Commit cf5aa66

Browse files
authored
Add specification for __setitem__ (#172)
1 parent 8a1602e commit cf5aa66

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

spec/API_specification/array_object.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,30 @@ Element-wise results must equal the results returned by the equivalent element-w
10621062
(method-__setitem__)=
10631063
### \_\_setitem\_\_(self, key, value, /)
10641064

1065-
_TODO: dependent on the indexing specification._
1065+
Sets `self[key]` to `value`.
1066+
1067+
#### Parameters
1068+
1069+
- **self**: _<array;>_
1070+
1071+
- array instance.
1072+
1073+
- **key**: _Union\[ int, slice, ellipsis, Tuple\[ Union\[ int, slice, ellipsis ], ... ], <array> ]_
1074+
1075+
- index key.
1076+
1077+
- **value**: _Union\[ int, float, bool, <array> ]_
1078+
1079+
- value(s) to set. Must be compatible with `self[key]` (see {ref}`broadcasting`).
1080+
1081+
```{note}
1082+
1083+
Setting array values must not affect the data type of `self`.
1084+
1085+
When `value` is a Python scalar (i.e., `int`, `float`, `bool`), behavior must follow specification guidance on mixing arrays with Python scalars (see {ref}`type-promotion`).
1086+
1087+
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.
1088+
```
10661089

10671090
(method-__sub__)=
10681091
### \_\_sub\_\_(self, other, /)

0 commit comments

Comments
 (0)