-
Notifications
You must be signed in to change notification settings - Fork 87
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 .attrs
to highlevel objects
#2757
Conversation
Design question (1) — should Return
|
The I think this is a good compromise, and it would follow the principle of least surprise if You were only asking about how it looks from the outside, so I'm voting "always return a dict." But since most users won't be using If we really need a Oh, unlike |
Actually,
Agreed. |
ffd0597
to
4a7361e
Compare
This PR indicates that it would be nice to have something like ctx = HighLevelCtx()
layouts = ctx.finalise([
ak.to_layout(ctx.maybe_highlevel(a)) for a in arrays
])
backend = ctx.backend
behavior = ctx.behavior Rather than the existing stateless functional API that revisits inputs multiple times. This function would ensure all layouts have the proper "final" backend. As such, it's on-hold for PR #2763 and another PR. |
bf62d43
to
c346295
Compare
b8f6058
to
78231ff
Compare
@jpivarski this is a big PR. I've split it into commits that should be a bit more manageable. I still need to do a pass to confirm that the various policy settings used by The purpose of the There's a test failure pertaining to the choice to permit records, that I'll revisit. |
Do we have a formal policy regarding which functions should prohibit/support record objects? e.g. |
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.
It is a big PR with a lot of differences, although many of them come from adding the single extra attrs
argument to lots of functions, which in many cases turns them from single-line to multi-line due to black.
The context object is a big difference. I see that this context object is private, for our own use, and I'm not certain that it's necessary for keeping track of two pieces of data (behavior
and attrs
), but it's fine.
(In your comment, I thought you were referring to a public context object, so that people can say,
with ak.Context(behavior, attrs):
ak.something...
although that doesn't make a lot of sense: one would want the behavior
and attrs
to be permanently glued to specific objects and not others. But I guess you were talking about a private context.)
I'm in favor of the direction that this PR is heading.
c8b34b2
to
eaec10a
Compare
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 a huge work, and tests/test_2757_attrs_metadata.py is very extensive, parameterizing over so many functions to make sure that attrs
are correctly passed through all of them.
My only request is about Numba: see below. If you have questions about that, I can help during our meeting tomorrow.
This will partially fix #1391 by adding
.attrs
, a dictionary of metadata that is associated with the top-level array, with the following semantics:@
) will be removed at serialisation time.Whilst touching some of this code, I did some work on type hints and refactoring.