This commit is contained in:
Ayush Chaurasia
2026-05-05 13:07:32 +05:30
parent 049a689a1c
commit 0c9f7c2bba
2 changed files with 3 additions and 19 deletions

View File

@@ -781,11 +781,10 @@ class Permutation:
def fetch(self, indices: list[int]) -> Any:
"""
Fetch rows from the permutation by offset.
Fetch rows from the permutation
This is the public batch-access API. It returns the rows for the given
offsets in the same shape as configured by
[with_format](#with_format) / [with_transform](#with_transform).
returns the rows for the given permutation in the same shape as configured by
with_format / with_transform.
Examples
--------

View File

@@ -1098,20 +1098,5 @@ def test_getitems_invalid_offset(some_permutation: Permutation):
def test_fetch_matches_getitems(some_permutation: Permutation):
"""Public fetch() should be equivalent to __getitems__."""
indices = [0, 1, 2, 10, 100]
assert some_permutation.fetch(indices) == some_permutation.__getitems__(indices)
def test_fetch_respects_format(some_permutation: Permutation):
"""fetch() applies the configured format/transform."""
arrow_perm = some_permutation.with_format("arrow")
result = arrow_perm.fetch([0, 1, 2])
assert isinstance(result, pa.RecordBatch)
assert result.num_rows == 3
def test_fetch_invalid_offset(some_permutation: Permutation):
"""fetch() with an out-of-range offset raises an error."""
with pytest.raises(Exception):
some_permutation.fetch([999999])