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

refactor: split "meta" into Meta #2841

Merged
merged 6 commits into from
Nov 20, 2023
Merged

refactor: split "meta" into Meta #2841

merged 6 commits into from
Nov 20, 2023

Conversation

agoose77
Copy link
Collaborator

@agoose77 agoose77 commented Nov 20, 2023

@jpivarski and I have discussed this on-and-off for over a year now.

Presently, ak.contents.Content subclasses re-use code from ak.forms.Form subclasses using explicit descriptor lookups. As such, ak.forms.Form serves as the implementation for many metadata methods. As we look to grow the set of metadata-only methods, it would be nice to formalise this hierarchy. Benefits include:

  • easier type checking
  • lower overhead (right now, e.g. Content.parameter involves an additional attribute lookup and function call)

As it now seems possible that we'll want an enforce_form function, I would like for the ability to implement the _mergeable_next protocol at the "meta" level, and doing this properly feels more readable (and easier to reason about) to me; we're not fighting the type system by implementing this via inheritance.

@agoose77 agoose77 force-pushed the agoose77/refactor-meta branch 4 times, most recently from 1578317 to 4dacbf4 Compare November 20, 2023 18:48
@agoose77
Copy link
Collaborator Author

I don't think we can / should group Type under Meta; types form a distinct group to forms and layouts.

refactor: move more metadata handling into meta

refactor: more typing

remove more to meta
@agoose77 agoose77 force-pushed the agoose77/refactor-meta branch from d0a0026 to 2fa362a Compare November 20, 2023 19:54
@agoose77 agoose77 requested a review from jpivarski November 20, 2023 19:57
@agoose77 agoose77 marked this pull request as ready for review November 20, 2023 19:57
Copy link
Member

@jpivarski jpivarski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we have been talking about this for a long time.

Sure, let's go ahead with this, but only if it isn't disruptive. From a user's or downstream developer's perspective, the Form and Content classes should appear to be as they have been (i.e. a pure refactor).

And yes, Types don't fit into this scheme.

Copy link

codecov bot commented Nov 20, 2023

Codecov Report

Merging #2841 (3388a16) into main (6ec2b07) will decrease coverage by 0.05%.
The diff coverage is 91.80%.

Additional details and impacted files
Files Coverage Δ
src/awkward/_meta/indexedmeta.py 100.00% <100.00%> (ø)
src/awkward/_meta/indexedoptionmeta.py 100.00% <100.00%> (ø)
src/awkward/_meta/listoffsetmeta.py 100.00% <100.00%> (ø)
src/awkward/contents/bitmaskedarray.py 69.28% <100.00%> (-0.30%) ⬇️
src/awkward/contents/bytemaskedarray.py 89.02% <100.00%> (-0.08%) ⬇️
src/awkward/contents/content.py 74.95% <100.00%> (-1.90%) ⬇️
src/awkward/contents/emptyarray.py 75.12% <100.00%> (-0.13%) ⬇️
src/awkward/contents/indexedarray.py 78.89% <100.00%> (-0.15%) ⬇️
src/awkward/contents/indexedoptionarray.py 88.44% <100.00%> (-0.08%) ⬇️
src/awkward/contents/listarray.py 90.71% <100.00%> (-0.06%) ⬇️
... and 31 more

@agoose77 agoose77 merged commit 028ba44 into main Nov 20, 2023
37 checks passed
@agoose77 agoose77 deleted the agoose77/refactor-meta branch November 20, 2023 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants