Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Type name mismatch for streamer and a corresponding branch for std::pair #175

Closed
plexoos opened this issue Oct 29, 2018 · 4 comments
Closed

Comments

@plexoos
Copy link
Contributor

plexoos commented Oct 29, 2018

There seems to be some inconsistency between the type name know to the streamer on file and the branch type when reading branches automatically created from std::pair members. I am reading a ROOT tree with a simple std::pair<Double_t, Double_t> member split into branches and get the following error:

...
File "uproot/uproot/tree.py", line 248, in _attachstreamer
KeyError: b'pair<Double_t,Double_t>'

However, a streamer for 'pair<double,double>' does exist and can be used to read the .first and .second subranches. I verified this by simply replacing 'Double_t' with 'double' in submembers[base]._fTypeName on line https://github.com/scikit-hep/uproot/blob/master/uproot/tree.py#L248 when encounter this branch.

Is this something that can be fixed by mapping ROOT types to their C equivalents? See https://root.cern.ch/doc/master/RtypesCore_8h_source.html#l00031

@jpivarski
Copy link
Member

Man, that's tough: I just get the streamer name as a string, not an object that can be broken down into components like that. In fact, I wonder why the name is different in different streamers...

To do this properly, we'd have to parse the strings as C++ and canonicalize them. (Part of why ROOT I/O needs Cling.) Fortunately, we know they're only types, which cuts out most of the language: types are identifiers, *, <...>, and [].

On the other hand, as long as it's only identifiers that are being mapped, a regular expression that matches at identifier boundaries would be valid— it could never confuse MuDouble_trigger for Double_t, for instance. It should be done once, when the streamers are loaded; that would be less dangerous than doing it in tree.py.

I'll give it a shot and point you to a branch to test. If it works for your file (and passes all the other tests), I'll include it.

@jpivarski jpivarski mentioned this issue Oct 29, 2018
@jpivarski
Copy link
Member

Try PR #176. That ought to take all strings like Double_t to double (and the full list from ROOT that you provided).

@plexoos
Copy link
Contributor Author

plexoos commented Oct 29, 2018

Yes, I confirm that this fixed my issue. Thank you!

@jpivarski
Copy link
Member

This will go into uproot 3.2.8 shortly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants