File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,6 @@ def plot(tree: Any) -> None:
5252
5353# Simpler in Python 3.11+
5454@plot .register (uproot .TBranch )
55- @plot .register (uproot .models .RNTuple .RField )
5655def plot_branch (tree : uproot .TBranch | uproot .models .RNTuple .RField ) -> None :
5756 """
5857 Plot a single tree branch.
@@ -71,6 +70,10 @@ def plot_branch(tree: uproot.TBranch | uproot.models.RNTuple.RField) -> None:
7170 plt .title (make_hist_title (tree , histogram ))
7271
7372
73+ if hasattr (uproot .models , "RNTuple" ) and hasattr (uproot .models .RNTuple , "RField" ):
74+ plot .register (uproot .models .RNTuple .RField )(plot_branch ) # type: ignore[no-untyped-call]
75+
76+
7477@plot .register
7578def plot_hist (tree : uproot .behaviors .TH1 .Histogram ) -> None :
7679 """
Original file line number Diff line number Diff line change @@ -57,9 +57,13 @@ def _(item: uproot.behaviors.TBranch.HasBranches) -> bool:
5757 return len (item .branches ) > 0
5858
5959
60- @is_dir .register
61- def _ (item : uproot .behaviors .RNTuple .HasFields ) -> bool :
62- return len (item .keys ()) > 0
60+ if hasattr (uproot .behaviors , "RNTuple" ) and hasattr (
61+ uproot .behaviors .RNTuple , "HasFields"
62+ ):
63+
64+ @is_dir .register
65+ def _ (item : uproot .behaviors .RNTuple .HasFields ) -> bool :
66+ return len (item .keys ()) > 0
6367
6468
6569def get_children (item : Mapping [str , Any ]) -> set [str ]:
@@ -159,7 +163,6 @@ def _process_item_tfile(
159163
160164# Python 3.11 can just use `|` directly for register
161165@process_item .register (uproot .TTree )
162- @process_item .register (uproot .behaviors .RNTuple .RNTuple )
163166def _process_item_ttree (
164167 uproot_object : uproot .TTree | uproot .behaviors .RNTuple .RNTuple ,
165168) -> MetaDict :
@@ -178,6 +181,9 @@ def _process_item_ttree(
178181 )
179182
180183
184+ process_item .register (uproot .behaviors .RNTuple .RNTuple )(_process_item_ttree ) # type: ignore[no-untyped-call]
185+
186+
181187@process_item .register
182188def _process_item_tbranch (uproot_object : uproot .TBranch ) -> MetaDict :
183189 """
You can’t perform that action at this time.
0 commit comments