diff --git a/python/sdss_semaphore/__init__.py b/python/sdss_semaphore/__init__.py index aa9fce3..45253d2 100644 --- a/python/sdss_semaphore/__init__.py +++ b/python/sdss_semaphore/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.2.3" +__version__ = "0.2.4" import numpy as np import warnings @@ -69,6 +69,11 @@ def __init__(self, array: Optional[Union[np.ndarray, Iterable[Iterable[int]], It self.array = np.atleast_2d(array).astype(self.dtype) return None + def __getitem__(self, index: int): + if isinstance(index, tuple): + raise IndexError("too many indices for array; you can only slice on items") + return self.__class__(self.array[[index]]) + @property def dtype(self): raise NotImplementedError(f"`dtype` must be defined in subclass") @@ -345,4 +350,4 @@ def __repr__(self): def __len__(self): N, B = self.array.shape - return N \ No newline at end of file + return N