feat: add public read-only ColorStops.lut_func property - #159
Draft
matthiasschabel wants to merge 1 commit into
Draft
matthiasschabel wants to merge 1 commit into
matthiasschabel wants to merge 1 commit into
Conversation
Colormap.__call__ always samples a 256-entry LUT, so colormaps defined by a function (prism, flag, gnuplot, cubehelix, ...) could only be evaluated exactly through the private ColorStops._lut_func. Expose the stored callable as a read-only property, returning it unwrapped (no clipping or RGBA padding), and None for stop-defined colormaps. Also correct the lut_func parameter docs: the callable receives an (N,) array and may return RGB or RGBA. Closes pyapp-kit#157. Co-Authored-By: Codex (gpt-6.1-sol) <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Reviewed-By: Claude (claude-opus-5-5)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #159 +/- ##
==========================================
+ Coverage 95.72% 95.95% +0.23%
==========================================
Files 168 168
Lines 2197 2200 +3
==========================================
+ Hits 2103 2111 +8
+ Misses 94 89 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Closes #157.
Adds a read-only
ColorStops.lut_funcproperty so colormaps defined by a function (prism, flag, gnuplot, cubehelix, ...) can be evaluated exactly at arbitrary positions, rather than through the 256-entry LUT thatColormap.__call__samples. It returns the stored callable unwrapped, so output is not clipped and may be RGB. ReturnsNonefor stop-defined colormaps. For a reversedColorStopsit returns the existing picklablepartial, which evaluatesf(1 - x).Also corrects the
lut_funcparameter docs: the callable receives an(N,)array (it is called withnp.linspace), not(N, 1), and may return RGB or RGBA.🤖 Generated with Claude Code