File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ # BSD 3-Clause License; see https://github.com/scikit-hep/uproot5/blob/main/LICENSE
2+
3+ import pytest
4+ import skhep_testdata
5+
6+ import uproot
7+
8+
9+ def test_field_class ():
10+ filename = skhep_testdata .data_path ("DAOD_TRUTH3_RC2.root" )
11+ with uproot .open (filename ) as f :
12+ obj = f ["RNT:CollectionTree" ]
13+ jets = obj ["AntiKt4TruthDressedWZJetsAux:" ]
14+ assert len (jets ) == 6
15+
16+ pt = jets ["pt" ]
17+ assert len (pt ) == 0
18+
19+
20+ def test_array_methods ():
21+ filename = skhep_testdata .data_path (
22+ "Run2012BC_DoubleMuParked_Muons_rntuple_1000evts.root"
23+ )
24+ with uproot .open (filename ) as f :
25+ obj = f ["Events" ]
26+ nMuon_array = obj ["nMuon" ].array ()
27+ Muon_pt_array = obj ["Muon_pt" ].array ()
28+ assert nMuon_array .tolist () == [len (l ) for l in Muon_pt_array ]
29+
30+ nMuon_arrays = obj ["nMuon" ].arrays ()
31+ assert len (nMuon_arrays .fields ) == 1
32+ assert len (nMuon_arrays ) == 1000
33+ assert nMuon_arrays ["nMuon" ].tolist () == nMuon_array .tolist ()
34+
35+ filename = skhep_testdata .data_path ("DAOD_TRUTH3_RC2.root" )
36+ with uproot .open (filename ) as f :
37+ obj = f ["RNT:CollectionTree" ]
38+ jets = obj ["AntiKt4TruthDressedWZJetsAux:" ].arrays ()
39+ assert len (jets [0 ].pt ) == 5
You can’t perform that action at this time.
0 commit comments