| 67 | |
| 68 | |
| 69 | class CustomArrayIndexable( |
| 70 | CustomArrayBase[_ShapeType_co, _DType_co], |
| 71 | ExplicitlyIndexed, |
| 72 | Generic[_ShapeType_co, _DType_co], |
| 73 | ): |
| 74 | def __getitem__( |
| 75 | self, key: _IndexKeyLike | CustomArrayIndexable[Any, Any], / |
| 76 | ) -> CustomArrayIndexable[Any, _DType_co]: |
| 77 | if isinstance(key, CustomArrayIndexable): |
| 78 | if isinstance(key.array, type(self.array)): |
| 79 | # TODO: key.array is duckarray here, can it be narrowed down further? |
| 80 | # an _arrayapi cannot be used on a _arrayfunction for example. |
| 81 | return type(self)(array=self.array[key.array]) # type: ignore[index] |
| 82 | else: |
| 83 | raise TypeError("key must have the same array type as self") |
| 84 | else: |
| 85 | return type(self)(array=self.array[key]) |
| 86 | |
| 87 | def __array_namespace__(self) -> ModuleType: |
| 88 | return np |
| 89 | |
| 90 | |
| 91 | def check_duck_array_typevar(a: duckarray[Any, _DType]) -> duckarray[Any, _DType]: |
no outgoing calls
searching dependent graphs…