diff --git a/src/dask_awkward/lib/core.py b/src/dask_awkward/lib/core.py index 26c5843a..6f8924dc 100644 --- a/src/dask_awkward/lib/core.py +++ b/src/dask_awkward/lib/core.py @@ -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(