Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski authored May 7, 2024
1 parent 86ef284 commit 7ab71bd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/uproot/writing/_cascadetree.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,11 @@ def _branch_np(
if letter is None:
raise TypeError(f"cannot write NumPy dtype {branch_dtype} in TTree")

if branch_shape == ():
dims = ""
else:
dims = "".join("[" + str(x) + "]" for x in branch_shape)
dims = ""
if counter is not None:
dims = "[" + counter["fName"] + "]"
if len(branch_shape) > 0:
dims = dims + "".join("[" + str(x) + "]" for x in branch_shape)

title = f"{branch_name}{dims}/{letter}"

Expand Down
21 changes: 21 additions & 0 deletions tests/test_1207_fix_title_of_TBranch_with_counter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot5/blob/main/LICENSE

import os

import awkward as ak

import uproot


def test(tmp_path):
filename = os.path.join(tmp_path, "file.root")

with uproot.recreate(filename) as file:
file["tree"] = {"branch": ak.Array([[1.1, 2.2, 3.3], [], [4.4, 5.5]])}

with uproot.open(filename) as file:
assert file["tree"]["branch"].title == "branch[nbranch]/D"
assert (
file["tree"]["branch"].member("fLeaves")[0].member("fTitle")
== "branch[nbranch]"
)

0 comments on commit 7ab71bd

Please sign in to comment.