Skip to content

Bucket A (1/2): refuse corrupt statistics: blocks, counts, ranges, tails, plane identity - #61

Merged
guijacquemet merged 1 commit into
mainfrom
claude/bucket-a
Nov 3, 2026
Merged

guijacquemet merged 1 commit into
mainfrom
claude/bucket-a

Conversation

@guijacquemet

@guijacquemet guijacquemet commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Bucket-A integrity fixes, statistics side: refuse corrupt pixel blocks, counts, ranges, tails and plane identity. The other half (parameters, scope column, unchecked channels) is #62. The two PRs merge cleanly into each other.

Fixes #25, fixes #26, fixes #31, fixes #42, fixes #43, fixes #44, fixes #45, fixes #46, fixes #47, fixes #48

Changes

Evidence

  • Regression tests: tests/test_integrity.py and two tests in test_scopes.py. Run against main (f784c95), 70 of the 91 integrity tests and all 4 new scope tests fail. The remaining 21 are controls that check valid inputs are still accepted.
  • Bitwise comparison: a dump of 5,769 outputs gives the same SHA-256 f7604ef1…c091417 on main, this branch and main + both PRs. It covers:
    • histograms for 10 dtypes × 3 bin counts × min-max/robust, whole, blockwise and with the range check;
    • CSV bytes and read-back;
    • pooled statistics, the linear percentile and WeightedHistogram;
    • fit, apply and from_columns round trips for 4 methods × 4 scope/pooling/per-time combinations;
    • pixel and patch fits, RGB, summaries and checks.
  • Gate:
    • ruff check . passes;
    • ruff format --check . passes;
    • ruff check --ignore-noqa . reports 3 E402 in tests/data/make_v2_fixture.py, the same 3 as on main;
    • pytest: 569 passed, 2 skipped (csbdeep not installed locally; the CI csbdeep job passed), 0 failed.
    • There is no tools/check.py or tools/code_rules.py in this repo.
  • Code standards:
    • histogram.py was already over the limit at 863 lines and is now 864. The _small_integer_histogram refactor offsets most of the new lines.
    • New and changed functions are ≤ 60 lines, C901 ≤ 15 and ≤ 8 parameters.
  • Performance: PooledHistogram of 200 uint16 planes takes 483 ms here against 509 ms on main (best of 5). This is a sanity check, not a performance claim.
  • Consumers: the full test suites of CellPatcher 438e6d4, MorphoFeature 9e66ca6 and morphobricks-preprocessing 83ce987, run against main + both PRs, have the same pass/fail sets as against main. The pre-existing failures are dependency-pin and installer tests.

🤖 Generated with Claude Code

https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc

Bucket-A integrity fixes for the statistics side of the brick. Valid inputs
give bit-identical outputs; invalid ones are refused with a named error
instead of being silently reinterpreted, wrapped or double-counted.

- Blocks: every non-empty block must hold the plane's pixel type; a block in
  the other byte order is converted by value, so big-endian 8/16-bit planes
  are no longer read as native-endian bytes (#25, #26).
- New integrity module: PlaneHistogram and HistogramTail check their
  invariants when made (int64 non-negative counts, exact unwrapped totals,
  valid <= total, all-or-none ordered finite limits, feasible tail sums with
  float64 overflow accepted only where the range allows it) (#45, #46, #47).
- plane_histograms.csv: a header-only table, overflowing counts and repeated
  plane_id rows are refused; write_plane_histograms, scope_groups, fit and
  image_summaries refuse repeated planes too (#43, #45, #48).
- PlaneRecord: z and t must be whole numbers 0 or above (#44).
- PooledHistogram adds counts as integers (exact above 2**53) and refuses a
  group above 2**63 - 1 pixels (#31).
- scope_groups refuses empty or non-text repeat-group labels and two
  biological repeats of one condition in one repeat group (#42).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
@guijacquemet
guijacquemet marked this pull request as ready for review November 3, 2026 14:20
@guijacquemet
guijacquemet merged commit 2c4c9d1 into main Nov 3, 2026
8 checks passed
@guijacquemet
guijacquemet deleted the claude/bucket-a branch November 3, 2026 14:38
@guijacquemet
guijacquemet restored the claude/bucket-a branch November 3, 2026 14:54
@guijacquemet
guijacquemet deleted the claude/bucket-a branch November 14, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants