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

Revert unproject_layout's action; use shape_touched in column optimization. #317

Closed
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/dask_awkward/lib/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def _necessary_columns(dsk: HighLevelGraph) -> dict[str, list[str]]:
"""Pair layer names with lists of necessary columns."""
kv = {}
for name, report in _get_column_reports(dsk).items():
cols = {_ for _ in report.data_touched if _ is not None}
cols = {_ for _ in report.data_touched + report.shape_touched if _ is not None}
select = []
for col in sorted(cols):
if col == name:
Expand Down
7 changes: 4 additions & 3 deletions src/dask_awkward/lib/unproject_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ def unproject_layout(form: Form | None, layout: Content) -> Content:
not appear in the projected layout will be PlaceholderArrays).

"""
if form is None:
return layout
return _unproject_layout(form, layout, layout.length, layout.backend)
return layout
# if form is None:
# return layout
# return _unproject_layout(form, layout, layout.length, layout.backend)
3 changes: 3 additions & 0 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def test_json_bytes_no_delim_defined(ndjson_points_file: str) -> None:


def test_to_and_from_dask_array(daa: dak.Array) -> None:
daa = dak.from_awkward(daa.compute(), npartitions=3)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the normal daa fixture is an array that comes from parquet, and the form ends up getting a mask when we do column selection. We avoid the mask by going ahead and computing the parquet-originating collection and creating a new collection from the concrete result via from_awkward. A bit roundabout but we still test what we mean to test here.

computed = ak.flatten(daa.points.x.compute())
x = dak.flatten(daa.points.x)
daskarr = dak.to_dask_array(x)
Expand Down Expand Up @@ -273,6 +274,8 @@ def test_from_lists(caa_p1: ak.Array) -> None:
def test_to_dask_array(daa: dak.Array, caa: dak.Array) -> None:
from dask.array.utils import assert_eq as da_assert_eq

daa = dak.from_awkward(daa.compute(), npartitions=4)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above


da = dak.to_dask_array(dak.flatten(daa.points.x))
ca = ak.to_numpy(ak.flatten(caa.points.x))
da_assert_eq(da, ca)
Expand Down
Loading