-
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
fix: add return_value='simplified' to ak.transform and revamp ak.firsts/ak.singletons #1968
Conversation
…nsform, and revamp ak.firsts
Codecov Report
Additional details and impacted files
|
…//github.com/scikit-hep/awkward into jpivarski/revamp-ak.firsts-and-ak.singletons
The main thing that will look different to an ordinary user is that
So for However, by reimplementing them with modern machinery ( So that's it from me: if you approve of these changes, let me know! |
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 general, I like this PR. I like the cleanups particularly.
I want to talk about the choice to move recursively_apply
to a private method. I don't want this conversation to distract from the review, so I'll put this as a separate discussion
I'd be most happy if we split the recursively_apply
rename into a separate PR to discuss separately. In that case, this PR gets a green light from me already.
However, I know that there is a time pressure here, so if you feel so strongly about #1969 and this particular part of the refactor, then it's your call - I do support merging this as-is.
Co-authored-by: Angus Hollands <[email protected]>
@agoose77 Now this PR does not hide |
The first commit touches a lot of files because it propagates
Content.simplified
throughrecursively_apply
, which was only partially done by #1939.It also changes the
ak.transform
API to take areturn_value = "none" | "original" | "simplified"
argument instead ofreturn_array = False | True
. Theak.transform
function hasn't gotten out into the wild (much) yet, so this is a chance to make that parameter an n-way enum, rather than grow into a bunch of booleans that are only sometimes meaningful (likereturn_simplified
andreturn_array
; the first means nothing if the second is False).This should have been done earlier, but
Content._recursively_apply
is now a hidden implementation detail. Theak.transform
API is the public one that we'll support. Having two ways of doing the same thing is opening the door to inconsistency.All of that was a stepping-stone to revamping
ak.firsts
. I didn't change its behavior within testing scope, but implementing it in terms ofContent._recursively_apply
is more robust. Branching layouts should now work automatically; they wereNotImplementedError
before.After revamping
ak.singletons
, I'll mark this ready for review.📚 The documentation for this PR will be available at https://awkward-array.readthedocs.io/en/jpivarski-revamp-ak.firsts-and-ak.singletons/ once Read the Docs has finished building 🔨