-
Notifications
You must be signed in to change notification settings - Fork 89
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
refactor: improve broadcasting logic readability #2359
Conversation
Codecov Report
Additional details and impacted files
|
def continuation(): | ||
# Any EmptyArrays? | ||
if any(x.is_unknown for x in contents): | ||
return broadcast_any_unknown() | ||
|
||
# Any NumpyArrays with ndim != 1? | ||
elif any(x.is_numpy and x.purelist_depth != 1 for x in contents): | ||
return broadcast_any_nd_numpy() | ||
|
||
# Any IndexedArrays? | ||
elif any((x.is_indexed and not x.is_option) for x in contents): | ||
return broadcast_any_indexed() | ||
|
||
# Any UnionArrays? | ||
elif any(x.is_union for x in contents): | ||
return broadcast_any_union() | ||
|
||
# Any option-types? | ||
elif any(x.is_option for x in contents): | ||
return broadcast_any_option() | ||
|
||
# Any list-types? | ||
elif any(x.is_list for x in contents): | ||
return broadcast_any_list() | ||
|
||
# Any RecordArrays? | ||
elif any(x.is_record for x in contents): | ||
return broadcast_any_record() | ||
|
||
else: | ||
raise ak._errors.wrap_error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the end, this is the summary, the high-level overview of how broadcasting works. Splitting it out like this really helps to see this big picture! (And it's safer in that it limits variable scope.)
This PR splits the continuation in broadcasting into separate closures that we can more easily refactor.