Skip to content

RGB: check before fitting, refuse incompatible dtypes, subset selection, apply intermediates - #78

Merged
guijacquemet merged 5 commits into
mainfrom
claude/rgb-50-53
Nov 7, 2026
Merged

guijacquemet merged 5 commits into
mainfrom
claude/rgb-50-53

Conversation

@guijacquemet

Copy link
Copy Markdown
Contributor

Fixes #50, fixes #51, fixes #52, fixes #53.

Commits 2 and 3 of the series carry a fix-up (stray from __future__ lines, fitting.py over the 600-line limit); the checks moved to rgb.py. Pushed history was not rewritten.

Bitwise result: tools/dump_outputs.py SHA-256 is dfd5e740...537e on main and on this branch. That dump has no RGB or apply coverage, so an RGB fit + apply digest (sha256 a2280b3e...2c09, uint8/uint16, pixels/conditions pooling, contiguous/views/float input) was also taken: identical on main and on this branch. The csbdeep parity tests are skipped locally (csbdeep not installed); the csbdeep CI job covers them.

Gate: python tools/check.py passes, 702 passed, 2 skipped (csbdeep).


Generated by Claude Code

fit() built one histogram per channel of a pixel array before check_rgb
refused a wrong channel count or a float type. The check now runs first for
pixel arrays, so invalid RGB input is refused before any work. Valid inputs
are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VbytvF3Gsa85ix8Ne2yMDW
…ing (#51)

fit() pooled the R, G and B histograms of all rows of a group even when the
images were, for example, uint8 and uint16, so the 16-bit images dominated
the shared offset and scale. It now raises IncompatibleSummariesError naming
the images and their types before any pooling. Single-type groups are
unchanged. Fluorescence fits are not changed here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VbytvF3Gsa85ix8Ne2yMDW
…, #52)

Follow-up to the two previous commits, which pushed fitting.py past the
600-line limit and included stray `from __future__` lines in __init__.py and
_version.py. The pixel-array check (#52) and the single-pixel-type check (#51)
are now check_rgb_pixels and check_rgb_records in rgb.py; messages and
behaviour are unchanged, and the stray lines are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VbytvF3Gsa85ix8Ne2yMDW
select([2]) on RGB parameters returned an object that serialized as one
channel, which from_columns then refused because RGB needs C0, C1 and C2.
RGB parameters keep the three channels together (contract section 5), so a
strict subset now raises ValueError naming the alternatives; selecting all
channels and fluorescence subsets are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VbytvF3Gsa85ix8Ne2yMDW
…aries (#53)

apply_rgb copied the pixels to float32, then allocated a subtraction result
and a division result. The two steps now write into the copy (np.subtract and
np.divide with out=), with the same float32 operations in the same order, so
the output is bitwise unchanged and still never shares memory with the input.
The peak allocation falls from about three float32 images to one; it was
measured only with tracemalloc in a test, not benchmarked for speed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VbytvF3Gsa85ix8Ne2yMDW
@guijacquemet
guijacquemet marked this pull request as ready for review November 7, 2026 03:44
@guijacquemet
guijacquemet merged commit e7e5d31 into main Nov 7, 2026
8 checks passed
@guijacquemet
guijacquemet deleted the claude/rgb-50-53 branch November 7, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment