-
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: hide Content recursion entry points in ak._do
submodule.
#1972
Conversation
…nsform, and revamp ak.firsts
…//github.com/scikit-hep/awkward into jpivarski/revamp-ak.firsts-and-ak.singletons
Co-authored-by: Angus Hollands <goosey15@gmail.com>
Codecov Report
Additional details and impacted files
|
At this point, Content has an API that will not be hard to maintain: L2: 📂 Form handling: 📂
Type properties: 📂
Extended type properties: 📂
Aspects: 📂
Constructors: 📂
Python interface: 📂
Sorting: 🔧
Packing: 🔧
Conversion:
Form properties: 📂
TypeTracer access: 📂
Equality:
Validity:
Option-type API: only applies to layouts for which
List-type API: only applies to layouts for which
Also,
IndexedArray API: 📂
UnionArray API: 📂
RecordArray API: 📂
NumpyArray API: 📂
EmptyArray API: 📂
But I have to fix These lists were generated using import awkward as ak
layouts = [
x for x in [getattr(ak.contents, x) for x in dir(ak.contents)]
if isinstance(x, type) and issubclass(x, ak.contents.Content)
]
Content_api = sorted([x for x in dir(ak.contents.Content) if not x.startswith("_")])
for x in Content_api:
print(x)
for x in sorted(layouts, key=lambda x: x.__name__):
print(x.__name__, sorted([y for y in dir(x) if not y.startswith("_") and not y in Content_api])) and a lot of editing. |
I have checked the entire public API of Awkward Array, and I think what we have, at the end of this PR, is something we can support. We can add things at any time, and we can change the mechanism by which hidden things are hidden (such as refactoring this Most of what I removed from the The merging system especially had to be hidden, since that was full of historical choices. (For example, when the |
Rename suggestions: |
All L3 are underscored, but added to a set of safe rules.
|
|
This is a proposed solution to #1969. While we have to hide
recursively_apply
somehow before the 2.0.0 release, there's nothing final about doing it this way. Since this is a hidden submodule, we can rename it or even change back to methods with a naming convention.This is for any function
X
that needs to be accessible throughout the Awkward codebase but hidden from outside the codebase, the first of which isrecursively_apply
. Here's an example program flow:ak.operations
callsak._do.recursively_apply(layout, *args)
. They can do this because hidden submodules (like_broadcasting
,_slicing
,_connect
, ...) can be called from anywhere in the Awkward codebase, but not by outsiders.ak._do
are allowed to callContent
andRecord
private methods. (Maybe it should have been calledak._sudo
.)ak._do.recursively_apply
decides whetherlayout
is aContent
or aRecord
and calls its_recursively_apply
private method.Content._recursively_apply
callsContent._recursively_apply
because we have another rule that says thatSubclass1._methodA
is allowed to callSubclass2._methodB
ifSubclass1 == Subclass2 or _methodA == _methodB
.I'm making up rules left and right, but rules are supposed to help us organize things, not constrain us, and these rules only apply within the Awkward codebase. For communication with the outside world, we have to limit ourselves to only the community-established conventions, such as "leading underscore means don't call it from outside."
(Also note that the program flow sketched above does not go out of
Content
back intoContent
, which would be a little confusing. It goes fromak.*
toak._do
toContent
.)I'll add other entry points to this PR as separate commits.
📚 The documentation for this PR will be available at https://awkward-array.readthedocs.io/en/jpivarski-hide-recursion-entry-points/ once Read the Docs has finished building 🔨