Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: evaluate iterator when selection=True #2308

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/evaluate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ def test_evaluate_iterator(df_local, chunk_size, prefetch, parallel):
assert total == z.sum()


def test_evaluate_iterator_selection(df_local):
df = df_local
bool_expr = df.x > 9
with small_buffer(df):
df.select(bool_expr)
x = df[bool_expr].x.to_numpy()
z = df[bool_expr].z.to_numpy()
total = 0
for i1, i2, chunk in df.evaluate_iterator('x', selection=True, chunk_size=3, array_type='numpy-arrow'):
assert x[i1:i2].tolist() == chunk.tolist()
total += chunk.sum()
assert total == x.sum()

total = 0
for i1, i2, chunk in df.evaluate_iterator('z', selection=True, chunk_size=3, array_type='numpy-arrow'):
assert z[i1:i2].tolist() == chunk.tolist()
total += chunk.sum()
assert total == z.sum()


@pytest.mark.parametrize("chunk_size", [2, 5])
@pytest.mark.parametrize("parallel", [True, False])
@pytest.mark.parametrize("array_type", ['numpy', 'list', 'xarray'])
Expand Down