File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,6 @@ def plot(tree: Any) -> None:
52
52
53
53
# Simpler in Python 3.11+
54
54
@plot .register (uproot .TBranch )
55
- @plot .register (uproot .models .RNTuple .RField )
56
55
def plot_branch (tree : uproot .TBranch | uproot .models .RNTuple .RField ) -> None :
57
56
"""
58
57
Plot a single tree branch.
@@ -71,6 +70,10 @@ def plot_branch(tree: uproot.TBranch | uproot.models.RNTuple.RField) -> None:
71
70
plt .title (make_hist_title (tree , histogram ))
72
71
73
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
+
74
77
@plot .register
75
78
def plot_hist (tree : uproot .behaviors .TH1 .Histogram ) -> None :
76
79
"""
Original file line number Diff line number Diff line change @@ -57,9 +57,13 @@ def _(item: uproot.behaviors.TBranch.HasBranches) -> bool:
57
57
return len (item .branches ) > 0
58
58
59
59
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
63
67
64
68
65
69
def get_children (item : Mapping [str , Any ]) -> set [str ]:
@@ -159,7 +163,6 @@ def _process_item_tfile(
159
163
160
164
# Python 3.11 can just use `|` directly for register
161
165
@process_item .register (uproot .TTree )
162
- @process_item .register (uproot .behaviors .RNTuple .RNTuple )
163
166
def _process_item_ttree (
164
167
uproot_object : uproot .TTree | uproot .behaviors .RNTuple .RNTuple ,
165
168
) -> MetaDict :
@@ -178,6 +181,12 @@ def _process_item_ttree(
178
181
)
179
182
180
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
+
181
190
@process_item .register
182
191
def _process_item_tbranch (uproot_object : uproot .TBranch ) -> MetaDict :
183
192
"""
You can’t perform that action at this time.
0 commit comments