Tuple for outer/orthogonal indexing. All elements should be int, slice or 1-dimensional np.ndarray objects with an integer dtype. Indexing is applied independently along each axis, and axes indexed with an integer are dropped from the result. This type of indexing works like MATLAB/
| 504 | |
| 505 | |
| 506 | class OuterIndexer(ExplicitIndexer): |
| 507 | """Tuple for outer/orthogonal indexing. |
| 508 | |
| 509 | All elements should be int, slice or 1-dimensional np.ndarray objects with |
| 510 | an integer dtype. Indexing is applied independently along each axis, and |
| 511 | axes indexed with an integer are dropped from the result. This type of |
| 512 | indexing works like MATLAB/Fortran. |
| 513 | """ |
| 514 | |
| 515 | __slots__ = () |
| 516 | |
| 517 | def __init__( |
| 518 | self, |
| 519 | key: tuple[BasicIndexerType | np.ndarray[Any, np.dtype[np.generic]], ...], |
| 520 | ): |
| 521 | if not isinstance(key, tuple): |
| 522 | raise TypeError(f"key must be a tuple: {key!r}") |
| 523 | |
| 524 | new_key = [] |
| 525 | for k in key: |
| 526 | if isinstance(k, integer_types) and not isinstance(k, bool): |
| 527 | k = int(k) |
| 528 | elif isinstance(k, slice): |
| 529 | k = as_integer_slice(k) |
| 530 | elif is_duck_array(k): |
| 531 | if not np.issubdtype(k.dtype, np.integer): |
| 532 | raise TypeError( |
| 533 | f"invalid indexer array, does not have integer dtype: {k!r}" |
| 534 | ) |
| 535 | if k.ndim > 1: # type: ignore[union-attr] |
| 536 | raise TypeError( |
| 537 | f"invalid indexer array for {type(self).__name__}; must be scalar " |
| 538 | f"or have 1 dimension: {k!r}" |
| 539 | ) |
| 540 | k = duck_array_ops.astype(k, np.int64, copy=False) |
| 541 | else: |
| 542 | raise TypeError( |
| 543 | f"unexpected indexer type for {type(self).__name__}: {k!r}, {type(k)}" |
| 544 | ) |
| 545 | new_key.append(k) |
| 546 | |
| 547 | super().__init__(tuple(new_key)) |
| 548 | |
| 549 | |
| 550 | class VectorizedIndexer(ExplicitIndexer): |
no outgoing calls
no test coverage detected
searching dependent graphs…