Repository navigation
Bucket A (2/2): refuse invalid parameters and channel indices; report unchecked channels - #62
Merged
Merged
Conversation
Bucket-A integrity fixes for the parameter side of the brick. Valid inputs give bit-identical outputs. - New parameter_checks module: Parameters and NormalizationParameters refuse a non-finite offset and a scale that is not finite and above zero when made, naming the channel or method (#36). - Channel indices of Parameters and Parameters.select must be whole numbers 0 or above; booleans, fractions, whole floats and text are refused instead of truncated by int() (#38). - Parameters.from_columns refuses a normalization_scope that is not one of the contract's scopes (#37, first part; comparing it with the settings' scope would break CellPatcher's parameters_from_row and the contract's own round-trip test, so it is left to an owner decision). - image_summaries gives Histogram_Exact None, not True, for a channel without finite pixels; new unchecked_channels returns a channel_without_finite_pixels warning for each such channel, separate from the four intensity_checks codes the calling bricks list (#57). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
guijacquemet
marked this pull request as ready for review
November 3, 2026 14:20
This was referenced Nov 3, 2026
This was referenced Nov 3, 2026
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.
Bucket-A integrity fixes, parameter side. The statistics side is #61. The two PRs merge cleanly; combined,
fitting.pyis 599 lines.Fixes #36, fixes #38. Refs #37, refs #57. Both are partly fixed and stay open; the reasons are below.
Changes
New
parameter_checks.py([Sad Catapella N3][Correctness] Direct Parameters/NormalizationParameters accept invalid offsets and scales #36):ParametersandNormalizationParametersrefuse, when constructed:The message names the channel or method. Non-finite pixels still pass through
applyunchanged.fitstill gives its existing zero-spread message.Channel indices ([Sad Catapella N3][Data integrity] Parameter channel indices silently truncate fractions and booleans #38):
Parameters.channelsandselectaccept Python or NumPy integers ≥ 0 only. Bool, 1.9, 1.0,"1", -1 andNoneare refused instead of being truncated byint().Scope column ([Sad Catapella N3][Scientific integrity] Parameter deserialization does not verify normalization_scope against requested settings #37, partial):
from_columnsrefuses anormalization_scopeoutsidebiological_repeat/image/patch, for exampleexperimentor a blank value.settings.scope. CellPatcher'sparameters_from_rowbuilds settings without a scope (so the default isimage) and reads rows of every scope. The repo's owntest_columns_round_trip_exactlyalso readspatchrows with default settings.scope=.Unmeasured channels ([Sad Catapella N7][Scientific QC] Entirely nonfinite channels produce no warning and are labelled Histogram_Exact=true #57, partial):
ImageSummary.exact, and soHistogram_Exact_C<i>, is nowNoneinstead ofTruefor a channel without finite pixels.unchecked_channels(summaries)returns onechannel_without_finite_pixelswarning per affected image and channel.intensity_checks. Preprocessing's notebook doescounts[issue.code] += 1over a fixed four-code dict, so a fifth code would raiseKeyErrorthere. Preprocessing has to adopt the new function to present the warning.Docs: contract §7.1, §8 (Validity row, scope), §9.1, §9.2; AGENTS map; README.
Evidence
tests/test_parameter_checks.py, 31 tests. Againstmain, 24 fail; the other 7 check that valid inputs are still accepted.f7604ef1…c091417on main, this branch and the combined merge. The only intended output change isexactfor channels with no finite pixels, which are not among the valid inputs in the dump.ruff check .andruff format --check .pass;--ignore-noqareports the same 3 pre-existing E402 as main;pytest: 505 passed, 2 skipped (csbdeep), 0 failed;Parameters,selectandfrom_columnsare used by CellPatcher (normalization.py:276,284,372,437,609) with valid integer channels and positive scales, so nothing breaks.🤖 Generated with Claude Code
https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc