fix: keep TTree branch lookup indices valid when a generated counter collides - #1698
Draft
ariostas wants to merge 1 commit into
Draft
fix: keep TTree branch lookup indices valid when a generated counter collides#1698ariostas wants to merge 1 commit into
ariostas wants to merge 1 commit into
Conversation
Tree._branch_lookup maps a branch name to its index in Tree._branch_data. When
a jagged branch's generated counter name matched a branch that had already been
declared, the colliding datum was removed with 'del self._branch_data[...]',
which shifts every later datum down by one while _branch_lookup keeps pointing
at the old indices.
mktree with scalar 'nx', scalar 'y' and jagged 'x' produced the lookup
{'nx': 1, 'y': 1, 'x': 2}: 'y' aliased the generated counter, and extending the
tree failed. Replace the datum in place instead, which also keeps the counter
ahead of the jagged branch it counts.
Assisted-by: claude-code:claude-opus-5[1m]
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Addresses finding 1 of "PR 5" in #1688.
Tree._branch_lookupmaps a branch name to its index inTree._branch_data. When a jagged branch's generated counter name collides with a branch that was already declared, the colliding datum was removed withdel:https://github.com/scikit-hep/uproot5/blob/main/src/uproot/writing/_cascadetree.py#L203-L207
which shifts every later datum down by one, while
_branch_lookupkeeps pointing at the old indices.yaliases the generated counter, and extending the tree fails.Replaces the datum in place instead. That also keeps the counter ahead of the jagged branch it counts, since a colliding name must have been declared before the branch that generates it.
Note this needs
mktreeto reproduce: since v5.7.0 dict assignment produces an RNTuple, which does not go through this code.Tests
tests/test_1688_cascadetree_counter_lookup.py: the lookup invariant (every name resolves to the datum carrying that name), a write/read round trip for the colliding schema, the existing "provided both as an explicit array and generated as a counter" error still firing when they disagree, and a non-colliding schema as a control. 2 of the 4 fail onmain.Full suite passes locally (1027 passed, 90 skipped).