Repository navigation
Refuse a missing pixel_min or pixel_max instead of filling it in (#47) - #65
Merged
Merged
Conversation
PlaneHistogram.__post_init__ filled a missing pixel_min with binning_min and a missing pixel_max with binning_max before check_histogram ran, so a plane_histograms.csv row with valid pixels and one blank extremum was silently accepted. The fallback is removed: every limit of a plane with valid pixels must be given. - histogram.py: the two internal callers that relied on the fallback (the min-max histogram of the 8/16-bit table path and the min-max branch of _bin_pass) now pass pixel_min and pixel_max explicitly. - integrity.py: the refusal names the missing or non-finite limit(s). - csv_io.py: a blank limit of a channel with valid pixels is refused naming its column. - tests: one-at-a-time missing limits, in memory and in the file; empty channels still read with blank limits; test helpers pass the extrema. - tools/dump_outputs.py: bit-exact dump of histograms, CSV round trips, pooling, summaries, checks and fits for valid inputs, with its SHA-256, so the unchanged-output claim can be reproduced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
This was referenced Nov 4, 2026
Merged
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 #47
Bug
At v0.3.3 (
320f304),PlaneHistogram.__post_init__filled a missingpixel_minwithbinning_minand a missingpixel_maxwithbinning_max, and only then rancheck_histogram(). Aplane_histograms.csvrow with valid pixels, a blankIntensity_MinIntensity_C0and a populatedHistogram_BinningMin_C0was therefore accepted with a value made up from another column.Fix
histogram.py: the fallback is gone. If a plane has valid pixels, all four limits must be given. A plane with no valid pixels still has all four set toNone._table_histogram.min_max, the min-max histogram for 8- and 16-bit planes;_bin_passwithextrema is None, the min-max branch for floats and wider integers.No separate constructor was needed.
integrity.py: the refusal now names each limit that is missing or not finite, for examplepixel_min is missing or not finite.csv_io.py: if a channel has valid pixels and one of its limits is blank, theCsvFormatErrornames that column, for exampleIntensity_MinIntensity_C0 is blank, but the channel has 4 valid pixel(s).tools/. The version is not bumped.Tests
Noneone at a time is refused, with the field named. A robust histogram with a missingpixel_minorpixel_maxis refused. Computed min-max histograms carry their extrema.singleton,histogram(), and the v2 fixture reader, which reads the v2pixel_min/pixel_maxcolumns.origin/main, the 10 new cases fail. Thepixel_min/pixel_maxcases fail because the value is silently filled in; the binning cases fail only on the new message.Bitwise unchanged outputs
tools/dump_outputs.pyis committed with this PR. It dumps the following for simulated planes of all supported dtypes, withfloat.hexfor every float:histogram_with_range_check(including theRangeCheck);plane_histograms.csvbytes (sha256) and the records read back;PooledHistogramstatistics;image_summariesandintensity_checks;fitfor 4 methods × 2 scopes.The dump is 1788 lines. Both runs used the same environment: Python 3.13, the repo's dev deps, and the script from this branch.
origin/main320f304 (viaPYTHONPATH=<worktree of main>/src)d82a9f97dc39d7851f1cee0d22b85ac442f92acbaef7b02892ea55ba6a4e218bd82a9f97dc39d7851f1cee0d22b85ac442f92acbaef7b02892ea55ba6a4e218bThe two dumps are also identical byte for byte (
cmp).To reproduce:
Consumer impact (read-only
git grep origin/main)79dd68e):tests/test_schema_v2_equivalence.py:134buildsPlaneHistogram(...)from v2 rows withoutpixel_min/pixel_max. It will be refused once preprocessing pins the next tag; it should passpixel_min/pixel_maxfrom the v2 columns, as this PR does in its own copy of that test.src/only uses the type in annotations and callscompute_*, so it is unaffected.40a68b1): only type annotations andcompute_plane_histogram. Unaffected.1e6a610): no references.Gate (local)
ruff check .: all checks passedruff format --check .: 43 files already formattedpytest: 622 passed, 2 skipped. The 2 skipped tests aretests/test_rgb.py, which needcsbdeep; the CI csbdeep job runs them.Note:
histogram.pywas already 864 lines before this PR, over the 600-line standard. This PR makes it slightly shorter but does not split it.Generated by Claude Code