Skip to content

test: enforce 100% line and branch coverage on Codecov - #1834

Open
ariostas wants to merge 37 commits into
scikit-hep:mainfrom
ariostas:test/enforce-coverage
Open

ariostas wants to merge 37 commits into
scikit-hep:mainfrom
ariostas:test/enforce-coverage

Conversation

@ariostas

@ariostas ariostas commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

The last PR of the split of #1814, to merge after all the others. Until then, it targets main and contains their commits. Its own change is the last commit, "test: enforce 100% line and branch coverage on Codecov":

  • codecov.yml requires 100% of the project and of each patch, and pyproject.toml turns on branch coverage. Codecov counts the CPU job plus the CUDA 13 GPU job (after_n_builds: 2), since some RNTuple code only runs on the GPU.
  • Code that can't be reached is marked with # pragma: no cover (reason) or # pragma: no branch (reason). Impossible elif chains end with raise AssertionError(...), which coverage excludes. That exclusion also covers about 30 raise AssertionError lines that were already in src/; the review of this PR checked the ones that could matter (the abstract placeholders of AsContainer, Container, Interpretation and Library, the _length_bytes checks, and TBranch basket ranges) and found none reachable.
  • Dead code is removed, including the code that dev/make-models.py generated after an unconditional raise. The generator is changed too, so it doesn't come back.
  • AGENTS.md describes the coverage rule, and the README gets a coverage badge.

With all the PRs below, the full suite has 100% line and branch coverage in a container that mirrors the coverage job (apart from the GPU-only code, which the CUDA job covers).

PR Contents
#1824 fix: interpretations (containers, object and string arrays, libraries, identification)
#1825 fix: file reading and sources (HTTP, XRootD, empty requests, uproot.dask with grouped TBranches)
#1826 fix: variances of unweighted histogram bins of negative content
#1827 fix: writing (keys past 2 GB, streamers, TTrees, TArray dtypes, directory cycles)
#1828 fix: RNTuple reading and writing, on the CPU and the GPU
#1823 test: changes to existing tests and fixtures that don't depend on the fixes
#1841 test: interpretations (replaces #1829, which was merged into test/existing-tests by mistake)
#1830 test: file reading, sources and utilities
#1831 test: models and histograms
#1832 test: TTree and RNTuple reading APIs
#1833 test: writing

The fix PRs and #1823 are independent of each other, and the five test PRs only need #1823, which is merged, so they now target main.

These were found by the tests of scikit-hep#1814, which are the regression tests here.
The fixes are to containers (std::map, C arrays, AsDynamic and AsArray
equality and hashing), strided and object arrays, the Awkward and Pandas
libraries, string baskets, typename parsing, Float16/Double32 titles, TLeafG,
TRef, TBasket.array, and model pickling.

The reset_classes fixture now puts the original model classes back after
the test, so that tests running after it in the same process (with
pytest-xdist) compare against the classes they looked up.

Assisted-by: Claude Code:claude-opus-5-5
These were found by the tests of scikit-hep#1814, which are the regression tests here.
The fixes are to HTTP and XRootD sources (closing responses, empty requests,
readline at the end of a stream), the deflate decompressor, streamer
dependencies, TBranch steps inside already-read baskets, paths into
RNTuples, files without streamers, cuts that aren't strings, and grouped
TBranches in uproot.dask.

Assisted-by: Claude Code:claude-opus-5-5
These were found by the tests of scikit-hep#1814, which are the regression tests here.
The fixes are to keys that move or grow past 2 GB, streamers added after
others, TTree type specifications and categorical strings, TArray classes
from dtypes, histogram conversion, directory listings of names without
cycles, copying directories, and extending TTrees with branches that Uproot
can't interpret, which includes custom interpretations without a dtype: the
methods of the Interpretation base class raise NotImplementedError, naming
the subclass, instead of a bare AssertionError.

Assisted-by: Claude Code:claude-opus-5-5
Like ROOT's TH1::GetBinError, the variance of a bin without fSumw2 is the
absolute value of its content, rather than 0 when the content is negative.
TProfile gets _values_variances, which the histogram conversions use. Found
by the tests of scikit-hep#1814.

Assisted-by: Claude Code:claude-opus-5-5
These were found by the tests of scikit-hep#1814, which are the regression tests here.
The fixes are to columns of narrower representations (zigzag, delta and
truncated or quantized floats), GPU reads of uncompressed and multi-page
columns, split columns of unsupported widths, unknown field roles, field
paths, linked attribute sets, anchors past 2 GB, and writing empty and
masked arrays.

Assisted-by: Claude Code:claude-opus-5-5
Changes to existing tests from scikit-hep#1814 that don't depend on its fixes: they
check values instead of only running, restore checks that had been dropped,
close the files they open, and run concurrently (each XRootD server has its
own admin path and waits until it accepts connections, and reset_classes puts
the original model classes back).

Assisted-by: Claude Code:claude-opus-5-5
@ariostas
ariostas force-pushed the test/enforce-coverage branch from a58f12a to 12c2405 Compare November 6, 2026 15:10
update_streamers rejected an object that isn't a streamer in the middle of
its loop, after the streamers before it had been recorded but before space
was made for them. A retry then skipped those streamers as already known,
and the file's list of streamers couldn't be read back.

Assisted-by: Claude Code:claude-opus-5-5
numpy.abs keeps the dtype, and the absolute value of the lowest integer of a
dtype doesn't fit in it, so a TH1C bin of -128 had a variance of -128 (and
TH1S, TH1I, TH2 and TH3 likewise).

Assisted-by: Claude Code:claude-opus-5-5
@ariostas
ariostas force-pushed the test/enforce-coverage branch from 12c2405 to 3da3c16 Compare November 6, 2026 15:21
@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b4acc0f) to head (4c57e39).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
Files with missing lines Coverage Δ
src/uproot/_awkwardforth.py 100.00% <100.00%> (+8.62%) ⬆️
src/uproot/_dask.py 100.00% <100.00%> (+12.63%) ⬆️
src/uproot/_util.py 100.00% <100.00%> (+32.93%) ⬆️
src/uproot/behaviors/RNTuple.py 100.00% <100.00%> (+22.09%) ⬆️
src/uproot/behaviors/TBranch.py 100.00% <100.00%> (+12.12%) ⬆️
src/uproot/behaviors/TGraphAsymmErrors.py 100.00% <ø> (+21.21%) ⬆️
src/uproot/behaviors/TH1.py 100.00% <100.00%> (+16.89%) ⬆️
src/uproot/behaviors/TH2.py 100.00% <100.00%> (+5.66%) ⬆️
src/uproot/behaviors/TH3.py 100.00% <100.00%> (+21.05%) ⬆️
src/uproot/behaviors/TProfile.py 100.00% <100.00%> (+14.12%) ⬆️
... and 34 more

... and 40 files with indirect coverage changes

WritableDirectory.values() returned every cycle of each name, while
keys(), items() and classnames() without cycles, and the values() of a
ReadOnlyDirectory, return each name once, as its highest cycle.

Assisted-by: Claude Code:claude-opus-5-5
mktree (and the cascade under it) silently left out a branch whose name was
already taken, including fields of records whose flattened names collided
with another branch: {"r_x": ..., "r": {"x": ..., "y": ...}} made a
TTree with only r_x and r_y, which could never be extended. Now a name
defined twice raises a ValueError. A scalar integer branch may still name
the counter of a jagged branch defined before it.

Assisted-by: Claude Code:claude-opus-5-5
Version 3 of TStreamerElement writes fXmin, fXmax and fFactor after its
type name (later versions take the range from the title instead), and
reading one stopped before them, so a file with version 3 elements failed
to deserialize. The format for them was defined but unused.

Assisted-by: Claude Code:claude-opus-5-5
Children after the first were indented two spaces less than the first.

Assisted-by: Claude Code:claude-opus-5-5
Assisted-by: Claude Code:claude-opus-5-5
The ROOT fixture also declared writers that only the tests of scikit-hep#1832 use, and
if any of them didn't compile with some ROOT version, the tests here would
fail too. The fixture also restores gErrorIgnoreLevel if a declaration fails.

Assisted-by: Claude Code:claude-opus-5-5
Six tests (of Future.result timeouts, ThreadPoolExecutor.shutdown, the order
of LRUCache, and Library equality) were deleted here in favor of tests in
scikit-hep#1829, scikit-hep#1830 and scikit-hep#1832, which are based on this PR; until those are merged
nothing else would cover them. They are now deleted together with the tests
that replace them. A comment no longer points to a file of scikit-hep#1828.

Assisted-by: Claude Code:claude-opus-5-5
New tests from scikit-hep#1814, apart from the regression tests of its fixes.

Assisted-by: Claude Code:claude-opus-5-5
MET_pt is in one TBasket, so with steps of 15 entries the later steps of a
file had nothing to request, and the XRootD source then sent an empty vector
read, which failed now and then. scikit-hep#1825 stops sending it; until then, these
tests iterate in one step per file.

Assisted-by: Claude Code:claude-opus-5-5
The check that a sequence isn't equal to a string passed for anything but
True. The test of Node.__str__ expected its wrong indentation, which scikit-hep#1824
fixes; it is now there, with the right one. The test of Library equality in
test_0016 is deleted here, as test_names_and_equality covers it.

Assisted-by: Claude Code:claude-opus-5-5
New tests from scikit-hep#1814, apart from the regression tests of its fixes.

Assisted-by: Claude Code:claude-opus-5-5
New tests from scikit-hep#1814, apart from the regression tests of its fixes.

Assisted-by: Claude Code:claude-opus-5-5
The test of closing an fsspec source with failing workarounds now checks
that both were tried, and the test of splitting XRootD ranges checks the
sizes of the vector-read elements. The local HTTP server polls for shutdown
every 0.01 s instead of 0.5 s, which every test waited for. The two tests of
test_1654 that test_1830_cov_io_futures.py replaces are deleted here.

Assisted-by: Claude Code:claude-opus-5-5
The edges of the variable-width axis spanned exactly fXmin to fXmax, so the
test couldn't tell the mean of the widths from (fXmax - fXmin) / fNbins. The
files that Rewritable opens are now closed after each test. The test of a
version 3 TStreamerElement leaves for scikit-hep#1824, which reads its range.

Assisted-by: Claude Code:claude-opus-5-5
New tests from scikit-hep#1814, apart from the regression tests of its fixes.

Assisted-by: Claude Code:claude-opus-5-5
New tests from scikit-hep#1814, apart from the regression tests of its fixes.

Assisted-by: Claude Code:claude-opus-5-5
The ROOT fixture also declared classes and writers that only the tests of
scikit-hep#1828 use; if any of them didn't compile with some ROOT version, the tests
here would fail too. gErrorIgnoreLevel is now restored if something fails
while it's lowered. The four LRUCache tests of test_1661 that
test_1832_cov_api_cache.py replaces are deleted here.

Assisted-by: Claude Code:claude-opus-5-5
…files

Four tests skipped without ROOT before checking anything with uproot; now
only their ROOT checks need it. The test of updating a file object closes
both files. The test that the first of two branches with the same name was
kept leaves for scikit-hep#1827, which rejects such names instead.

Assisted-by: Claude Code:claude-opus-5-5
With the tests of the previous PRs, every reachable line and branch is
covered. Codecov now requires 100% of the project and of each patch, with
branch coverage. Code that can't be reached is marked with
"# pragma: no cover  (reason)" or "# pragma: no branch  (reason)", ends
impossible elif chains with "raise AssertionError" (excluded from coverage),
or is removed when it was dead, including the dead code that
dev/make-models.py generated after unconditional raises.

Assisted-by: Claude Code:claude-opus-5-5

This branch has not been deployed

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

Labels

type/test PR title type: test (set automatically)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant