fix: RNTuple/TBranch behavior edge cases (KeyInFileError, global iterate offsets, ak_add_doc forwarding)#1658
Open
henryiii wants to merge 3 commits into
Open
fix: RNTuple/TBranch behavior edge cases (KeyInFileError, global iterate offsets, ak_add_doc forwarding)#1658henryiii wants to merge 3 commits into
henryiii wants to merge 3 commits into
Conversation
- RNTuple HasFields.__getitem__ else branch (non-recursive miss) now uses self.ntuple.parent._file.file_path / self.path, matching sibling branches, so RField['.missing'] raises KeyInFileError instead of AttributeError; fixes .get() and 'in' on RField as well - Module-level RNTuple.iterate now tracks global_offset across files, applying library.global_index and Report.to_global per batch, matching the TBranch.iterate pattern; fixes report=True and pandas index continuity across multi-file iteration - Forward ak_add_doc in TBranch leaf-branch delegates: _eager_arrays and parent.iterate calls from the leaf shortcut paths now pass ak_add_doc= - Remove unused private class _WrapDict from TBranch.py - Rename local report variable to rep in TBranch module-level iterate to avoid shadowing the boolean parameter Part of #1646 Assisted-by: ClaudeCode:claude-sonnet-4-6
Add tests covering: - RField.__getitem__ raises KeyInFileError (not AttributeError) for non-recursive miss, plus .get() and 'in' on RField - module-level RNTuple.iterate continuous global_entry_start/stop across multiple files, and correct total entry counts without report - leaf TBranch .arrays() and .iterate() forward ak_add_doc argument Assisted-by: ClaudeCode:claude-sonnet-4-6
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
|
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 🤖
Part of #1646
Summary
Fix 1 (RNTuple
HasFields.__getitem__error path): Theelsebranch (non-recursive miss) was usingself._file.file_path/self.object_path, which only exist onRNTuplebut not onRField. This causedfield[".nonexistent"]to raiseAttributeErrorinstead ofuproot.KeyInFileError, which also broke.get()andinoperator onRField. The fix makes the else branch useself.ntuple.parent._file.file_path/self.path, matching the sibling branches.Fix 2 (RNTuple module-level
iterateglobal offsets): The module-leveluproot.behaviors.RNTuple.iteratewas usingyield from, so withreport=Truethe entry reports restarted at 0 for each file and pandas indexes weren't shifted. Ported the TBranch pattern: trackglobal_offset, applylibrary.global_indexandreport.to_globalper batch, advance by the file'snum_entries.Fix 3 (
ak_add_docforwarding in leaf-branch delegates): When a leafTBranch's.arrays()delegates toself.parent._eager_arrays(...)and.iterate()delegates toself.parent.iterate(...), theak_add_docargument was dropped. Addedak_add_doc=ak_add_docat both delegation sites.Fix 4 (remove dead code): Deleted unused private class
_WrapDictfromTBranch.py— referenced nowhere in the codebase.Fix 5 (local variable shadowing): Renamed local
reportvariable torepin the TBranch module-level iterate loop body to avoid shadowing the booleanreportparameter.Test plan
tests/test_1658_fix_behaviors_misc.py— 7 regression tests covering all 5 fixestests/test_1630_rntuple_iterate_report.py— existing RNTuple iteration with report teststests/test_0832_ak_add_doc_should_also_add_to_typetracer.py— existing ak_add_doc teststests/test_1375_extend_ak_add_doc.py— existing ak_add_doc teststests/test_1406_improved_rntuple_methods.py— existing RNTuple method tests