Skip to content

Invalid data for collections from a frame indexed in the same line in python #642

@jmcarcell

Description

@jmcarcell

The issue is the following, when indexing a frame iterator and using it in the same line:

import podio
podio_reader = podio.root_io.Reader("example_frame.root")
frames = podio_reader.get("events")
print(len(frames[0].get('mcparticles')))  # prints a random number like 811654108391827

the number printed is consistent with reading some random memory (64 bits). Or if the number is too big, the error will be:

OverflowError: cannot fit 'int' into an index-sized integer

The workaround is easy, just save the intermediate frame (explaining why this has not been before since typically one will loop over the frames):

ev = frames[0]
print(len(ev.get('mcparticles')))  # prints 10, all is good here

From this it just seems that frames[0] is not constructed properly in python. Any other operation that I have tried will also fail.

It seems not to be an issue with podio (leaving only cppyy), at least not with the python code, because if we get down to the functions that are actually being called and do:

print(podio.Frame(cppyy.gbl.std.move(podio_reader._reader.readEntry("events", 0))).get('mcparticles').size())

this will also print a random number. I'll try to prepare an example to report this to cppyy if that is the case (looks like).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions