Skip to content

Commit

Permalink
better error message
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasdavis committed Jul 20, 2023
1 parent cf2fc37 commit f38c2e6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/dask_awkward/lib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,16 @@ def map_partitions(
kwarg_flat_deps, kwarg_repacker = unpack_collections(kwargs, traverse=traverse)
flat_deps, _ = unpack_collections(*args, *kwargs.values(), traverse=traverse)

if len(flat_deps) == 0:
message = (
"map_partitions expects at least one Dask collection instance, "
"you are passing non-Dask collections to dask-awkward code.\n"
"observed argument types:\n"
)
for arg in args:
message += f"- {type(arg)}"
raise TypeError(message)

arg_flat_deps_expanded = []
arg_repackers = []
arg_lens_for_repackers = []
Expand Down
8 changes: 8 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,3 +812,11 @@ def test_dask_array_in_map_partitions(daa, caa):
def test_dask_awkward_Array_copy(daa):
c = copy.copy(daa)
assert_eq(daa, c)


def test_map_partitions_no_dask_collections_passed(caa):
with pytest.raises(
TypeError,
match="map_partitions expects at least one Dask collection",
):
dak.num(caa.points.x, axis=1)

0 comments on commit f38c2e6

Please sign in to comment.