MCPcopy Create free account
hub / github.com/PyTables/PyTables / __getitem__

Method __getitem__

tables/index.py:2076–2095  ·  view source on GitHub ↗

Return the indices values of index in the specified range. If key argument is an integer, the corresponding index is returned. If key is a slice, the range of indices determined by it is returned. A negative value of step in slice is supported, meaning that the resul

(self, key: int | slice)

Source from the content-addressed store, hash-verified

2074 return (start, stop, step)
2075
2076 def __getitem__(self, key: int | slice) -> int | np.ndarray:
2077 """Return the indices values of index in the specified range.
2078
2079 If key argument is an integer, the corresponding index is returned.
2080 If key is a slice, the range of indices determined by it is returned.
2081 A negative value of step in slice is supported, meaning that the
2082 results will be returned in reverse order.
2083
2084 This method is equivalent to :meth:`Index.read_indices`.
2085
2086 """
2087 if is_idx(key):
2088 key = operator.index(key)
2089
2090 if key < 0:
2091 # To support negative values
2092 key += self.nelements
2093 return self.read_indices(key, key + 1, 1)[0]
2094 elif isinstance(key, slice):
2095 return self.read_indices(key.start, key.stop, key.step)
2096
2097 def __len__(self) -> int:
2098 return self.nelements

Callers

nothing calls this directly

Calls 3

read_indicesMethod · 0.95
is_idxFunction · 0.85
indexMethod · 0.80

Tested by

no test coverage detected