diff --git a/src/dask_awkward/lib/structure.py b/src/dask_awkward/lib/structure.py index fc0bbf09..6780b30c 100644 --- a/src/dask_awkward/lib/structure.py +++ b/src/dask_awkward/lib/structure.py @@ -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 @@ -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: diff --git a/tests/test_structure.py b/tests/test_structure.py index 23a190b4..53d4efcf 100644 --- a/tests/test_structure.py +++ b/tests/test_structure.py @@ -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(