Repository navigation
Document check_white, optical_density and rgb_yxc as stable API (P2 of the H&E tissue mask) - #108
Merged
Merged
Conversation
New contract §3.6: the three optical-density helpers preprocessing's H&E tissue mask calls are stable public API, with their signatures, units, dtypes, the floor, the (od, floored_fraction) pair, every refusal in order and what "stable" means. They stay module attributes (a root re-export of optical_density would shadow its module). tests/test_stable_od_api.py pins the import paths, signatures, one behaviour each and the refusal types. No code or output change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
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.
Prerequisite P2 of preprocessing's H&E tissue-mask helper (I1): morphobricks-preprocessing
docs/design/he-tissue-mask.mdatce650e3, §9 P2 and owner decision Q5. Documentation and tests only, based on main9616e12.What changes
docs/contract.md§3.6 (new), "Stable optical-density helpers for other bricks", plus a pointer from §3.4 and a row in the implementation table. For each ofoptical_density.optical_density(rgb: np.ndarray, white: np.ndarray) -> tuple[np.ndarray, float]optical_density.check_white(white: object) -> np.ndarrayscalar_inputs.rgb_yxc(pixels: np.ndarray, axes: str) -> np.ndarrayit gives the exact signature, the meaning, units and dtypes of each argument, and the return value.
optical_densityreturns the pair(od, floored_fraction):odis a new float64(Y, X, 3)array,-log10(max(I, 1) / white), with the floorFLOOR = 1.0;floored_fractionis a Pythonfloat.check_whitereturns a new float64(3,).rgb_yxcreturns a new C-contiguous uint8(Y, X, 3). The section also lists every refusal in the order it is tested, with its exception type and message text. None of these refusals has acodeor a message constant, and the section says so: they are programming-error refusals, so consumers match on the type.optical_densityhas no refusals of its own; its preconditions are the outputs of the other two functions.What "stable" means: the import paths, signatures, return types, dtypes and shapes, the formula and floor, and the refusals are all part of the contract. Changing any of them needs the owner's approval and a plan §12 entry, and ships as a Breaking release (a minor-version bump before 1.0).
Namespace: no code change. The functions are already public module attributes, and they stay that way, as the §3.4/§3.5 modules do. A root re-export of the function
optical_densitywould shadow the modulemorphobricks_normalization.optical_density, so the stable import paths are the module paths. These are the paths the design records.tests/test_stable_od_api.py(22 tests) pins:inspect.signatureof each function (parameter names, kinds, no defaults, annotations);__all__;optical_densitywithodfloat64(Y, X, 3)and afloatfraction;CHANGELOG
## Unreleasedentry.Identity
No file under
src/ortests/data/changes, so the parity tests and goldens stay byte-identical.Gate
python tools/check.pywithPYTEST_ADDOPTSunset passes (exit 0): ruff format, code rules and ruff check clean; 2740 passed, 2 skipped. Both skips aretests/test_rgb.py:82, the optionalcsbdeepcheck, which is not installed.Generated by Claude Code