Skip to content

Commit

Permalink
fix: refuse dak.Array in hidden-but-public-functions (#3079)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski authored Apr 20, 2024
1 parent b981aa5 commit 28d8917
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def backend(*arrays):
Args:
arrays: Array-like data (anything #ak.to_layout recognizes).
Returns the names of the backend used by `arrays`. This name may be
Returns the name of the backend used by `arrays`. This name may be
* `"cpu"` for arrays backed by NumPy;
* `"cuda"` for arrays backed by CuPy;
Expand Down
11 changes: 11 additions & 0 deletions src/awkward/typetracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def _length_0_1_if_typetracer(
) -> T:
typetracer_backend = TypeTracerBackend.instance()

if type(array).__module__.startswith("dask_awkward."):
raise TypeError(
"ak.typetracer._length_0_1_if_typetracer cannot take a dask-awkward Array; pass its '_meta' instead"
)

with HighLevelContext(behavior=behavior, attrs=attrs) as ctx:
layout = ctx.unwrap(
array,
Expand Down Expand Up @@ -149,6 +154,12 @@ def touch_data(
Recursively touches the data and returns a shall copy of the given array.
"""

if type(array).__module__.startswith("dask_awkward."):
raise TypeError(
"ak.typetracer.touch_data cannot take a dask-awkward Array; pass its '_meta' instead"
)

with HighLevelContext(behavior=behavior, attrs=attrs) as ctx:
layout = ctx.unwrap(
array,
Expand Down

0 comments on commit 28d8917

Please sign in to comment.