Skip to content

Commit

Permalink
Merge pull request #104 from hoetmaaiers/master
Browse files Browse the repository at this point in the history
Allow ResultSet slicing
  • Loading branch information
valeriupredoi authored Nov 25, 2024
2 parents cd65b58 + 88712bc commit 848f09b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pyesgf/search/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def __init__(self, context, batch_size=DEFAULT_BATCH_SIZE, eager=True):
self.__get_batch(0)

def __getitem__(self, index):
if isinstance(index, slice):
# Handle slicing
return [self[i] for i in range(*index.indices(len(self)))]

batch_i = index // self.batch_size
offset = index % self.batch_size
batch = self.__get_batch(batch_i)
Expand Down

0 comments on commit 848f09b

Please sign in to comment.