File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -50,8 +50,9 @@ def plot(tree: Any) -> None:
50
50
raise RuntimeError (msg )
51
51
52
52
53
- @plot .register
54
- def plot_branch (tree : uproot .TBranch ) -> None :
53
+ # Simpler in Python 3.11+
54
+ @plot .register (uproot .TBranch )
55
+ def plot_branch (tree : uproot .TBranch | uproot .models .RNTuple .RField ) -> None :
55
56
"""
56
57
Plot a single tree branch.
57
58
"""
@@ -69,6 +70,10 @@ def plot_branch(tree: uproot.TBranch) -> None:
69
70
plt .title (make_hist_title (tree , histogram ))
70
71
71
72
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
+
72
77
@plot .register
73
78
def plot_hist (tree : uproot .behaviors .TH1 .Histogram ) -> None :
74
79
"""
Original file line number Diff line number Diff line change @@ -57,6 +57,15 @@ def _(item: uproot.behaviors.TBranch.HasBranches) -> bool:
57
57
return len (item .branches ) > 0
58
58
59
59
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
67
+
68
+
60
69
def get_children (item : Mapping [str , Any ]) -> set [str ]:
61
70
return {
62
71
key .split (";" )[0 ]
@@ -152,8 +161,11 @@ def _process_item_tfile(
152
161
)
153
162
154
163
155
- @process_item .register
156
- def _process_item_ttree (uproot_object : uproot .TTree ) -> MetaDict :
164
+ # Python 3.11 can just use `|` directly for register
165
+ @process_item .register (uproot .TTree )
166
+ def _process_item_ttree (
167
+ uproot_object : uproot .TTree | uproot .behaviors .RNTuple .RNTuple ,
168
+ ) -> MetaDict :
157
169
"""
158
170
Given an tree, return a rich.tree.Tree output.
159
171
"""
@@ -169,6 +181,12 @@ def _process_item_ttree(uproot_object: uproot.TTree) -> MetaDict:
169
181
)
170
182
171
183
184
+ if hasattr (uproot .behaviors , "RNTuple" ) and hasattr (
185
+ uproot .behaviors .RNTuple , "HasFields"
186
+ ):
187
+ process_item .register (uproot .behaviors .RNTuple .RNTuple )(_process_item_ttree ) # type: ignore[no-untyped-call]
188
+
189
+
172
190
@process_item .register
173
191
def _process_item_tbranch (uproot_object : uproot .TBranch ) -> MetaDict :
174
192
"""
You can’t perform that action at this time.
0 commit comments