-
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
feat: add ak.merge_union_of_records
#2185
Conversation
Codecov Report
Additional details and impacted files
|
def apply_displace_index(layout, backend, **kwargs): | ||
if layout.is_record: | ||
return layout | ||
elif (layout.is_option or layout.is_indexed) and layout.content.is_record: |
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.
This is doing something different for is_option
. merge_option_of_records
…ords' into agoose77/feat-merge-union-of-records
…ords' into agoose77/feat-merge-union-of-records
@jpivarski what I'm not certain on here is what should happen for esoteric layouts that have multiple "option-of-record", and "union-of-record" in a single dimension. What should we do here, first wins? It seems like we do that in |
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.
I added some tests which include the original problem in #2182 and a variation of it that has already-optional fields (to verify that the simplified
classmethod is being used).
I also added tests for the ak.merge_option_of_records
, and the result is wrong; it drops Nones
, rather than merging them into the record fields. I'm labeling this review as "Approve" because once that's fixed and the tests pass, it will be ready to merge.
Oh, I didn't add any tests for different axis
values. Was that straightforward/formulaic? If it follows a pattern set by the many other functions that use axis
, then I don't think we need to explicitly test it.
Darn it, I just convinced myself that I really do need to test it. One moment...
Okay, tested it.
This PR addresses #2182. We already implement some of this machinery in
UnionArray
, which has a_union_of_optionarrays
method to convert fromoption[union[X, Y, Z]]
tounion[option[X], Y, ..., Z]
. It doesn't seem like that is particularly useful in this case.Interestingly there is some overlap with
ak._util.union_to_record
.Added functions
ak.merge_option_of_records
ak.merge_union_of_records