Skip to content

fix: RNTuple/TBranch behavior edge cases (KeyInFileError, global iterate offsets, ak_add_doc forwarding)#1658

Open
henryiii wants to merge 3 commits into
mainfrom
fix-behaviors-misc
Open

fix: RNTuple/TBranch behavior edge cases (KeyInFileError, global iterate offsets, ak_add_doc forwarding)#1658
henryiii wants to merge 3 commits into
mainfrom
fix-behaviors-misc

Conversation

@henryiii

@henryiii henryiii commented Jun 10, 2026

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

Part of #1646

Summary

  • Fix 1 (RNTuple HasFields.__getitem__ error path): The else branch (non-recursive miss) was using self._file.file_path / self.object_path, which only exist on RNTuple but not on RField. This caused field[".nonexistent"] to raise AttributeError instead of uproot.KeyInFileError, which also broke .get() and in operator on RField. The fix makes the else branch use self.ntuple.parent._file.file_path / self.path, matching the sibling branches.

  • Fix 2 (RNTuple module-level iterate global offsets): The module-level uproot.behaviors.RNTuple.iterate was using yield from, so with report=True the entry reports restarted at 0 for each file and pandas indexes weren't shifted. Ported the TBranch pattern: track global_offset, apply library.global_index and report.to_global per batch, advance by the file's num_entries.

  • Fix 3 (ak_add_doc forwarding in leaf-branch delegates): When a leaf TBranch's .arrays() delegates to self.parent._eager_arrays(...) and .iterate() delegates to self.parent.iterate(...), the ak_add_doc argument was dropped. Added ak_add_doc=ak_add_doc at both delegation sites.

  • Fix 4 (remove dead code): Deleted unused private class _WrapDict from TBranch.py — referenced nowhere in the codebase.

  • Fix 5 (local variable shadowing): Renamed local report variable to rep in the TBranch module-level iterate loop body to avoid shadowing the boolean report parameter.

Test plan

  • tests/test_1658_fix_behaviors_misc.py — 7 regression tests covering all 5 fixes
  • tests/test_1630_rntuple_iterate_report.py — existing RNTuple iteration with report tests
  • tests/test_0832_ak_add_doc_should_also_add_to_typetracer.py — existing ak_add_doc tests
  • tests/test_1375_extend_ak_add_doc.py — existing ak_add_doc tests
  • tests/test_1406_improved_rntuple_methods.py — existing RNTuple method tests

henryiii and others added 3 commits June 10, 2026 15:02
- 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

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.86%. Comparing base (1c06db0) to head (3968421).
⚠️ Report is 15 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
Files with missing lines Coverage Δ
src/uproot/behaviors/RNTuple.py 73.20% <100.00%> (+2.22%) ⬆️
src/uproot/behaviors/TBranch.py 84.36% <100.00%> (+1.04%) ⬆️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant