Skip to content

Commit

Permalink
fix: handle np.ndarray(N) where N is a scalar in compute results (
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasdavis authored Nov 1, 2023
1 parent 26f1928 commit 17dc9f6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/dask_awkward/lib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,13 +537,20 @@ def new_record_object(dsk: HighLevelGraph, name: str, *, meta: Any) -> Record:
def _finalize_array(results: Sequence[Any]) -> Any:
# special cases for length 1 results
if len(results) == 1:
if isinstance(results[0], (int, ak.Array)):
if isinstance(results[0], (int, ak.Array, np.ndarray)):
return results[0]

# a sequence of arrays that need to be concatenated.
elif any(isinstance(r, ak.Array) for r in results):
return ak.concatenate(results)

# a sequence of scalars that are stored as np.ndarray(N) where N
# is a number (i.e. shapeless numpy array)
elif any(isinstance(r, np.ndarray) for r in results) and any(
r.shape == () for r in results
):
return ak.Array(list(results))

# sometimes we just check the length of partitions so all results
# will be integers, just make an array out of that.
elif isinstance(results, (tuple, list)) and all(
Expand Down

0 comments on commit 17dc9f6

Please sign in to comment.