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

Commit

Permalink
Merge pull request #380 from scikit-hep/issue-367
Browse files Browse the repository at this point in the history
Fixes #367.
  • Loading branch information
jpivarski committed Oct 18, 2019
2 parents 98b9758 + ba6e04c commit eb5d886
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
Binary file added tests/samples/issue367.root
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import numpy

import uproot
import awkward

import uproot_methods.classes.TVector3
import uproot_methods.classes.TLorentzVector
Expand Down Expand Up @@ -213,3 +214,7 @@ def test_issue371(self):
assert obj._samplerName == b'DRIFT_0'
assert obj._n == 1
assert obj._energy[0] == numpy.array([2.3371024], dtype=numpy.float32)[0]

def test_issue367(self):
t = uproot.open("tests/samples/issue367.root")["tree"]
assert awkward.fromiter(t.array("weights.second"))[0].counts.tolist() == [1000, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 100, 100, 100, 1]
30 changes: 30 additions & 0 deletions uproot/interp/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,38 @@ def transform(node, tofloat=True):
if branch.name.endswith(b".first") and branch._fClassName.startswith(b"pair<string,"):
return asgenobj(SimpleArray(STLString(awkward)), branch._context, 6)

if branch.name.endswith(b".second"):
m = interpret._pairsecond.match(branch._fClassName)
if m is not None:
t, = m.groups()
if t == b"vector<bool>" or t == b"vector<Bool_t>":
return asgenobj(SimpleArray(STLVector(asdtype(awkward.numpy.bool_))), branch._context, 6)
elif t == b"vector<char>" or t == b"vector<Char_t>":
return asgenobj(SimpleArray(STLVector(asdtype("i1"))), branch._context, 6)
elif t == b"vector<unsigned char>" or t == b"vector<UChar_t>" or t == b"vector<Byte_t>":
return asgenobj(SimpleArray(STLVector(asdtype("u1"))), branch._context, 6)
elif t == b"vector<short>" or t == b"vector<Short_t>":
return asgenobj(SimpleArray(STLVector(asdtype("i2"))), branch._context, 6)
elif t == b"vector<unsigned short>" or t == b"vector<UShort_t>":
return asgenobj(SimpleArray(STLVector(asdtype("u2"))), branch._context, 6)
elif t == b"vector<int>" or t == b"vector<Int_t>":
return asgenobj(SimpleArray(STLVector(asdtype("i4"))), branch._context, 6)
elif t == b"vector<unsigned int>" or t == b"vector<UInt_t>":
return asgenobj(SimpleArray(STLVector(asdtype("u4"))), branch._context, 6)
elif t == b"vector<long>" or t == b"vector<Long_t>":
return asgenobj(SimpleArray(STLVector(asdtype("i8"))), branch._context, 6)
elif t == b"vector<unsigned long>" or t == b"vector<ULong64_t>":
return asgenobj(SimpleArray(STLVector(asdtype("u8"))), branch._context, 6)
elif t == b"vector<float>" or t == b"vector<Float_t>":
return asgenobj(SimpleArray(STLVector(asdtype("f4"))), branch._context, 6)
elif t == b"vector<double>" or t == b"vector<Double_t>":
return asgenobj(SimpleArray(STLVector(asdtype("f8"))), branch._context, 6)
elif t == b"vector<string>":
return asgenobj(SimpleArray(STLVector(STLString(awkward))), branch._context, 6)

return None

interpret._titlehasdims = re.compile(br"^([^\[\]]+)(\[[^\[\]]+\])+")
interpret._itemdimpattern = re.compile(br"\[([1-9][0-9]*)\]")
interpret._itemanypattern = re.compile(br"\[(.*)\]")
interpret._pairsecond = re.compile(br"pair\<[^<>]*,(.*) \>")
2 changes: 1 addition & 1 deletion uproot/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import re

__version__ = "3.10.6"
__version__ = "3.10.7"
version = __version__
version_info = tuple(re.split(r"[-\.]", __version__))

Expand Down

0 comments on commit eb5d886

Please sign in to comment.