2
2
3
3
__all__ = ["array" ]
4
4
5
+ from typing import SupportsIndex
5
6
from ._types import (
6
7
array ,
7
8
dtype as Dtype ,
@@ -604,11 +605,11 @@ def __ge__(self: array, other: Union[int, float, array], /) -> array:
604
605
def __getitem__ (
605
606
self : array ,
606
607
key : Union [
607
- int ,
608
+ SupportsIndex ,
608
609
slice ,
609
610
ellipsis ,
610
611
None ,
611
- Tuple [Union [int , slice , ellipsis , None ], ...],
612
+ Tuple [Union [SupportsIndex , slice , ellipsis , None ], ...],
612
613
array ,
613
614
],
614
615
/ ,
@@ -620,9 +621,13 @@ def __getitem__(
620
621
----------
621
622
self: array
622
623
array instance.
623
- key: Union[int , slice, ellipsis, None, Tuple[Union[int , slice, ellipsis, None], ...], array]
624
+ key: Union[SupportsIndex , slice, ellipsis, None, Tuple[Union[SupportsIndex , slice, ellipsis, None], ...], array]
624
625
index key.
625
626
627
+
628
+ .. note::
629
+ ``key`` can only be an array if it is valid for boolean array indexing, or supports ``__index__()``.
630
+
626
631
Returns
627
632
-------
628
633
out: array
@@ -1077,7 +1082,11 @@ def __rshift__(self: array, other: Union[int, array], /) -> array:
1077
1082
def __setitem__ (
1078
1083
self : array ,
1079
1084
key : Union [
1080
- int , slice , ellipsis , Tuple [Union [int , slice , ellipsis ], ...], array
1085
+ SupportsIndex ,
1086
+ slice ,
1087
+ ellipsis ,
1088
+ Tuple [Union [SupportsIndex , slice , ellipsis ], ...],
1089
+ array ,
1081
1090
],
1082
1091
value : Union [int , float , bool , array ],
1083
1092
/ ,
@@ -1089,11 +1098,13 @@ def __setitem__(
1089
1098
----------
1090
1099
self: array
1091
1100
array instance.
1092
- key: Union[int , slice, ellipsis, Tuple[Union[int , slice, ellipsis], ...], array]
1101
+ key: Union[SupportsIndex , slice, ellipsis, Tuple[Union[SupportsIndex , slice, ellipsis], ...], array]
1093
1102
index key.
1094
1103
value: Union[int, float, bool, array]
1095
1104
value(s) to set. Must be compatible with ``self[key]`` (see :ref:`broadcasting`).
1096
1105
1106
+ .. note::
1107
+ ``key`` can only be an array if it is valid for boolean array indexing, or supports ``__index__()``.
1097
1108
1098
1109
.. note::
1099
1110
0 commit comments