Repository navigation
RGB: check before fitting, refuse incompatible dtypes, subset selection, apply intermediates - #78
Merged
Merged
Conversation
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
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.
Fixes #50, fixes #51, fixes #52, fixes #53.
fitchecks the RGB channel count, axis and pixel type before building any histogram (test counts zero histogram calls).IncompatibleSummariesErrornaming the images and types, before pooling. Fluorescence is not changed.Parameters.selecton RGB parameters refuses a strict subset of R, G, B (contract §5 already says the channels stay together); selecting all channels and fluorescence subsets are unchanged. Contract table updated.apply_rgbwrites the two float32 steps into its one copy (out=), same operations and order. Peak allocation is tested with tracemalloc; no speed claim.Commits 2 and 3 of the series carry a fix-up (stray
from __future__lines,fitting.pyover the 600-line limit); the checks moved torgb.py. Pushed history was not rewritten.Bitwise result:
tools/dump_outputs.pySHA-256 isdfd5e740...537eon main and on this branch. That dump has no RGB orapplycoverage, so an RGB fit + apply digest (sha256a2280b3e...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.pypasses, 702 passed, 2 skipped (csbdeep).Generated by Claude Code