Skip to content

Commit

Permalink
awkward main has Scalars returns as np.ndarray(N)
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasdavis committed Nov 1, 2023
1 parent 26f1928 commit e3bcfa1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/dask_awkward/lib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,20 @@ def _finalize_array(results: Sequence[Any]) -> Any:
if len(results) == 1:
if isinstance(results[0], (int, ak.Array)):
return results[0]
if isinstance(results[0], np.ndarray) and results[0].shape == ():
return results[0].item()

# 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 e3bcfa1

Please sign in to comment.