Skip to content

Add __index__ to array object #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions spec/API_specification/array_object.md
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,27 @@ Computes the truth value of `self_i > other_i` for each element of an array inst
Element-wise results must equal the results returned by the equivalent element-wise function [`greater(x1, x2)`](elementwise_functions.md#greaterx1-x2-).
```

(method-__index__)=
### \_\_index\_\_(self, /)

Converts a zero-dimensional integer array to a Python `int` object.

```{note}
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/).
```

#### Parameters

- **self**: _<array>_

- zero-dimensional array instance. Must have an integer data type.

#### Returns

- **out**: _<int>_

- a Python `int` object representing the single element of the array instance.

(method-__int__)=
### \_\_int\_\_(self, /)

Expand Down