Skip to content

MomentumArray4D via ak.ArrayBuilder forces x,y,z,t fields #83

@lukasheinrich

Description

@lukasheinrich

This might just be a impl. detail - if so please close (or I move it to discussion)

When building a MomentumArray4D with ak.ArrayBuilder with the name keyword argument, I need to be careful to use x,y,z,t fieldnames and not px,py,pz,E (which I would have expected given that I pass MomentumArray4D as a name)

cc @jpivarski as a continuation of the discussion in #83

data = [
    {"px": 1., "py": 1.1, "pz": 0.1, 'E': 3.3},
    {"px": 2., "py": 2.2, "pz": 0.2, 'E': 3.3}
]


print(ak.type(vc.awk(data)))
print(vc.awk(data).mass)
print(vc.awk(data).px)

builder = ak.ArrayBuilder()
for d in data:
    with builder.record(name = 'Momentum4D'):
#        for f in d.keys():  fails
        for f,k in {'x':'px','y':'py','z': 'pz', 't': 'E'}.items():
            builder.field(f).real(d[k])
builder.snapshot().mass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions