docs: correct/complete NaN, masked, and infinity docs - #149
Open
matthiasschabel wants to merge 2 commits into
Open
docs: correct/complete NaN, masked, and infinity docs#149matthiasschabel wants to merge 2 commits into
matthiasschabel wants to merge 2 commits into
Conversation
The mask and the nan test were exclusive, so a masked array's unmasked nans were never found. Such a value survived to the int cast, where it became INT_MIN, and take(..., mode="clip") clipped it to index 0: nan rendered as the colormap's first ramp color instead of `bad`, silently and plausibly. The same values in a plain ndarray render correctly, so the two input types disagreed about identical data. `bad` is documented as the color for values that are "NaN or masked" (docs/faq.md), so this restores the stated contract. The nan test is applied only to float dtypes on the masked path, keeping object-dtype masked arrays working, and the mask is combined with `|` rather than `|=` so the caller's own mask is left alone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Reviewed-By: Codex (gpt-5.6-sol, reasoning effort xhigh)
The `bad` parameter was documented as the color for "(NaN, inf)" values, but infinities are not routed there: negative infinity uses `under` and positive infinity uses `over`, falling back to the first and last ramp colors when unset. `__call__`, the primary API, said nothing about exceptional values at all. Documents the routing where a reader looks for it: the constructor parameters, the under/over/bad attributes, `__call__`, and `lut`. The `__call__` text is scoped to float input, since integer input indexes the LUT directly and only leaves the ramp at or beyond N, or below 0. "When no ... color is set" rather than "if not provided", because a catalog entry can supply one (napari:HiLo, napari:nan). Documentation only; no behavior change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Reviewed-By: Codex (gpt-5.6-sol, reasoning effort xhigh)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #149 +/- ##
=======================================
Coverage 95.56% 95.57%
=======================================
Files 168 168
Lines 2186 2190 +4
=======================================
+ Hits 2089 2093 +4
Misses 97 97 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
matthiasschabel
marked this pull request as ready for review
August 9, 2026 22:48
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.
Depends on #148. This branch assumes that PR, so the diff below contains both. Only the second commit, e53f057, belongs to this one; #148 should be reviewed and merged first.
The
badparameter is documented as the color for "bad (NaN, inf) values" (src/cmap/_colormap.py:137), but infinities never reach it. Verified routing onmain:under_colorover_colorbad_colorInfinity is not special-cased anywhere; it falls out of the
xa < 0andxa >= Ncomparisons.Corrected in the four places a reader looks: the constructor parameters, the
under_color/over_color/bad_colorattributes,lut(which omitted masked values), and__call__, which was silent on all of this.Two details that shaped the wording:
__call__text is scoped to float input. Integer input indexes the LUT directly, so an integer 2 withN=4is a ramp color, not over; only an index at or beyond N leaves the ramp, and a negative index usesunder_colorrather than wrapping.napari:HiLocarries under and over,napari:nancarries bad).Documentation only. The masked-entry line is accurate once #148 lands; it matches what
docs/faq.mdalready promises.This PR doesn't touch the question of adding separate infinity colors from #144.