Skip to content

Commit

Permalink
Adds fLen computation and updating in the case of writing TLeafC.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioanaif authored Sep 22, 2023
1 parent f04d1a0 commit 88568cd
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/uproot/writing/_cascadetree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,26 @@ def write_updates(self, sink):

datum["arrays_write_start"] = datum["arrays_write_stop"]

if datum["dtype"] == ">U0":
position = (
base
+ datum["basket_metadata_start"]
- 25 # empty TObjArray of fBaskets (embedded)
- 8 # specialized TLeaf* members (fMinimum, fMaximum)
- 4 # null fLeafCount
- 14 # generic TLeaf members
)
sink.write(
position,
uproot.models.TLeaf._tleaf2_format0.pack(
self._metadata["fLen"],
datum["dtype"].itemsize,
0,
datum["kind"] == "counter",
_dtype_to_char[datum["dtype"]] != _dtype_to_char[datum["dtype"]].upper()
)
)

if datum["kind"] == "counter":
position = (
base
Expand Down Expand Up @@ -1439,9 +1459,10 @@ def write_jagged_basket(self, sink, branch_name, compression, array, offsets):
)
compressed_data = uproot.compression.compress(uncompressed_data, compression)

fLast = offsets[-1]
offsets[-1] = 0
#get size of biggest string
self._metadata["fLen"] = max( [offsets[i+1]-offsets[i] for i in range(len(offsets)-1)] )

fLast = offsets[-1]
fObjlen = len(uncompressed_data)
fNbytes = fKeylen + len(compressed_data)

Expand Down

0 comments on commit 88568cd

Please sign in to comment.