Skip to content

Commit 5e33e0d

Browse files
authored
Add __index__ to array object (#263)
1 parent 85d3170 commit 5e33e0d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

spec/API_specification/array_object.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,27 @@ Computes the truth value of `self_i > other_i` for each element of an array inst
654654
Element-wise results must equal the results returned by the equivalent element-wise function [`greater(x1, x2)`](elementwise_functions.md#greaterx1-x2-).
655655
```
656656

657+
(method-__index__)=
658+
### \_\_index\_\_(self, /)
659+
660+
Converts a zero-dimensional integer array to a Python `int` object.
661+
662+
```{note}
663+
This method is called to implement [`operator.index()`](https://docs.python.org/3/reference/datamodel.html#object.__index__). See also [PEP 357](https://www.python.org/dev/peps/pep-0357/).
664+
```
665+
666+
#### Parameters
667+
668+
- **self**: _<array>_
669+
670+
- zero-dimensional array instance. Must have an integer data type.
671+
672+
#### Returns
673+
674+
- **out**: _<int>_
675+
676+
- a Python `int` object representing the single element of the array instance.
677+
657678
(method-__int__)=
658679
### \_\_int\_\_(self, /)
659680

0 commit comments

Comments
 (0)