-
Notifications
You must be signed in to change notification settings - Fork 76
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: special case for reading std::string from a TDirectory #1160
Conversation
Actually, this second commit is less invasive, and it's setting up less of a precedent for special cases. The serialization of the The downside of this approach is that it returns the data as an instance of a class named |
Can we include your file as a test? Is https://cburr.web.cern.ch/string-example.root a stable address? |
Thank you for following up with this so quickly. I've tried this out and it works exactly the way I'd expect: In [1]: import uproot
...: import json
...: uproot.classes["string"] = uproot.classes["TString"]
...:
...: fn = "https://cburr.web.cern.ch/string-example.root"
...:
...: f2 = uproot.open(fn)
...: json.loads(f2["FileSummaryRecord"])
...:
Out[1]:
{'LumiCounter.eventsByRun': {'counts': {},
'empty': True,
'type': 'LumiEventCounter'},
'guid': '5FE9437E-D958-11EE-AB88-3CECEF1070AC'} I suspect
It can absolutely be included as a test though I'd suggest putting it somewhere else if you can as that URL likely won't last forever. It's only ~5KB. |
Well, if it's a special case in ROOT, it can be a special case in Uproot. I'm still not sure if I like the if self._fClassName == "string":
return cursor.string(chunk, context) or the uproot.classes["string"] = Model_TString better. The first option is "more hacky," or at least, more special of a special case, and the second is natural but has the downside of declaring that a Actually, that made my decision for me: we can't have Uproot insinuating that a |
* feat: add support for reading free floating std::vector * style: pre-commit fixes * Update test file name and ROOT import * style: pre-commit fixes * pytest import * move the check for STL classes earlier and ensure at least one type matches in the regex * style: pre-commit fixes * changed my mind; std::vector<T> might need T to be defined by streamers * update the fix for #1160 to be like this one, and remove the double-check for std::string * forgot to reinstate the 'cls is None and' --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jim Pivarski <jpivarski@gmail.com>
Fixes #1159.(That's a discussion.)What do you think, @chrisburr? Is
std::string
truly exceptional, such that a special case is warranted, or is this the tip of an iceberg that should be handled in a more systematic way?(If it's to be handled in a systematic way, I don't know when or by whom.)