Reading strings of the branches using uproot

57 views
Skip to first unread message

rajesh.p...@gmail.com

unread,
Aug 29, 2018, 12:20:37 PM8/29/18
to uproot users
Dear all,

I am trying to write the data in each leaf and branch of the attached root file into a new CSV file. For this purpose, I am trying to form an array out of each of the Leaves and Branches.  I could read all the data present in the Leaves but I am having difficulty reading the data from the Branches. I believe the Branches contain Strings. I have attached both of my ROOT file and python code in the following dropbox link:


Could you please take a look and help me solving this problem?

You can see where I am stuck at the very last line of the python code which I have commented out. You may uncomment that line and see the error message that ends with:

AttributeError: 'Source' object has no attribute 'path'


Kindly,

Rajesh

Jim Pivarski

unread,
Aug 30, 2018, 7:36:31 AM8/30/18
to uproot users
Hi! I'd prefer all bug reports to go to the GitHub issues tab because then I have a record all in one place of what I fixed and why.

Your issue is, in fact, a bug, and it's a misleading error message. It's an error while trying to construct an error message about running off the end of an internal buffer— but the real issue is that your branch type is being misinterpreted. It's a std::vector<std::string>, but it's not being interpreted that way, so I put in a missing check for this type in uproot/interp/auto.py.


However, this is a correction on the new 3.0 version. Going from uproot 2 (which you and everybody else is using) to uproot 3 (which I'll be releasing soon), all of the code that handles non-numerical objects, such as strings, has been replaced. If you can wait until the end of the day today and are willing to use a beta version, I'll be releasing 3.0.0b2 with your fix.

Would that be okay? Back-porting this correction into uproot 2.x wouldn't make a lot of sense because all of that object-handling code is now a dead end. It would only be if users couldn't use uproot 3.x for some reason. I'd rather not go the route Python did with supporting both version 2 and 3 for 10 years.

Jim Pivarski

unread,
Aug 30, 2018, 7:37:52 AM8/30/18
to uproot users
I removed the text from my reply where I said, "I didn't even know this group existed!"

It's good that I did, because apparently, I created it. 

Jim Pivarski

unread,
Aug 30, 2018, 7:53:10 AM8/30/18
to uproot users
From the same file, there's also this fix:


(you would have encountered it after the first one).

These are all easy fixes because we don't lack the code to interpret branches as strings or any other type, but there's a lot of different ways ROOT can express exactly what type a branch has. to exhaustively check all the special cases, we just have to encounter them "in the wild."

Thanks for providing this example!

Jim Pivarski

unread,
Aug 30, 2018, 5:16:16 PM8/30/18
to uproot users
Version 3.0.0b2 has been released! Since this is a beta version, you have to ask for it specially:

pip install -U "uproot>=3.0.0b2"

Let me know if that works for you.

Reply all
Reply to author
Forward
0 new messages