@@ -793,29 +793,31 @@ def __rand__(self, other) -> "DelayedArray":
793793 return _wrap_isometric_with_args (self , other , operation = "logical_and" , right = False )
794794
795795 # Subsetting.
796- def __getitem__ (self , subset : Tuple [ Union [ slice , Sequence ], ...] ) -> Union ["DelayedArray" , ndarray ]:
796+ def __getitem__ (self , subset ) -> Union ["DelayedArray" , ndarray ]:
797797 """Take a subset of this ``DelayedArray``. This follows the same logic as NumPy slicing and will generate a
798798 :py:class:`~delayedarray.Subset.Subset` object when the subset operation preserves the dimensionality of the
799799 seed, i.e., ``args`` is defined using the :py:meth:`~numpy.ix_` function.
800800
801801 Args:
802802 subset:
803- A :py:class:`tuple` of length equal to the dimensionality of
804- this ``DelayedArray``. We attempt to support most types of
805- NumPy slicing; however, only subsets that preserve
806- dimensionality will generate a delayed subset operation.
803+ A :py:class:`tuple` of length equal to the dimensionality of this ``DelayedArray``, or a single integer specifying an index on the first dimension.
804+ We attempt to support most types of NumPy slicing; however, only subsets that preserve dimensionality will generate a delayed subset operation.
807805
808806 Returns:
809- If the dimensionality is preserved by ``subset``, a
810- ``DelayedArray`` containing a delayed subset operation is returned.
811- Otherwise, a :py:class:`~numpy.ndarray` is returned containing the
812- realized subset.
807+ If the dimensionality is preserved by ``subset``, a ``DelayedArray`` containing a delayed subset operation is returned.
808+ Otherwise, a :py:class:`~numpy.ndarray` is returned containing the realized subset.
813809 """
810+ if not isinstance (subset , Tuple ):
811+ replacement = [slice (None )] * len (self .shape )
812+ replacement [0 ] = subset
813+ subset = (* replacement ,)
814+
814815 cleaned = _getitem_subset_preserves_dimensions (self .shape , subset )
815816 if cleaned is not None :
816817 sout = Subset (self ._seed , cleaned )
817818 sout = _simplify_subset (sout )
818819 return DelayedArray (sout )
820+
819821 return _getitem_subset_discards_dimensions (self ._seed , subset , extract_dense_array )
820822
821823
0 commit comments