Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle np.ndarray(N) where N is a scalar in compute results #401

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading