Skip to content

Commit

Permalink
Merge pull request #297 from cjtitus/rechunk_fix
Browse files Browse the repository at this point in the history
Fix minor bug in event_model's rechunk_event_pages
  • Loading branch information
danielballan authored Mar 28, 2024
2 parents bb2fa03 + 330566a commit 707a108
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions event_model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2772,7 +2772,8 @@ def page_chunks(page: dict, chunk_size: int, remainder: int) -> Generator:
for key in page["timestamps"].keys()
},
"filled": {
key: page["filled"][key][start:stop] for key in page["data"].keys()
key: page["filled"][key][start:stop]
for key in page["filled"].keys()
},
}

Expand Down Expand Up @@ -2831,7 +2832,7 @@ def merge_event_pages(event_pages: Iterable[EventPage]) -> EventPage:
key: list(
itertools.chain.from_iterable([page["filled"][key] for page in pages])
)
for key in pages[0]["data"].keys()
for key in pages[0]["filled"].keys()
},
)
return cast(EventPage, doc)
Expand Down
5 changes: 3 additions & 2 deletions event_model/tests/test_em.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,8 @@ def test_single_run_document_router():
sr("descriptor", desc_bundle.descriptor_doc)


def test_rechunk_event_pages():
@pytest.mark.parametrize("filled", [True, False])
def test_rechunk_event_pages(filled):
def event_page_gen(page_size, num_pages):
"""
Generator event_pages for testing.
Expand All @@ -851,7 +852,7 @@ def event_page_gen(page_size, num_pages):
**{key: list(range(page_size)) for key in array_keys},
"data": {key: list(range(page_size)) for key in data_keys},
"timestamps": {key: list(range(page_size)) for key in data_keys},
"filled": {key: list(range(page_size)) for key in data_keys},
"filled": {key: list(range(page_size)) for key in data_keys if filled},
}

# Get a list of event pages of size 13.
Expand Down

0 comments on commit 707a108

Please sign in to comment.