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: dak.copy should copy metadata #413

Merged
merged 2 commits into from
Nov 13, 2023
Merged
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
13 changes: 12 additions & 1 deletion src/dask_awkward/lib/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import builtins
import warnings
from collections.abc import Iterable, Mapping, Sequence
from copy import deepcopy
from numbers import Number
from typing import TYPE_CHECKING, Any

Expand Down Expand Up @@ -315,7 +316,17 @@ def combinations(

@borrow_docstring(ak.copy)
def copy(array: Array) -> Array:
return array
# Make a copy of meta, but don't try and copy the layout;
# dask-awkward's copy is metadata-only
old_meta = array._meta
new_meta = ak.Array(old_meta.layout, behavior=deepcopy(old_meta._behavior))

return Array(
array._dask,
array._name,
new_meta,
array._divisions,
)


class _FillNoneFn:
Expand Down
7 changes: 2 additions & 5 deletions tests/test_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,8 @@ def test_sort(daa, caa, ascending):


def test_copy(daa):
with pytest.raises(
DaskAwkwardNotImplemented,
match="This function is not necessary in the context of dask-awkward.",
):
dak.copy(daa)
result = dak.copy(daa)
assert result._meta is not daa._meta


@pytest.mark.parametrize(
Expand Down
Loading