Skip to content

feat: add public read-only ColorStops.lut_func property - #159

Draft
matthiasschabel wants to merge 1 commit into
pyapp-kit:mainfrom
matthiasschabel:feat/public-lut-func
Draft

matthiasschabel wants to merge 1 commit into
pyapp-kit:mainfrom
matthiasschabel:feat/public-lut-func

Conversation

@matthiasschabel

@matthiasschabel matthiasschabel commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #157.

Adds a read-only ColorStops.lut_func property so colormaps defined by a function (prism, flag, gnuplot, cubehelix, ...) can be evaluated exactly at arbitrary positions, rather than through the 256-entry LUT that Colormap.__call__ samples. It returns the stored callable unwrapped, so output is not clipped and may be RGB. Returns None for stop-defined colormaps. For a reversed ColorStops it returns the existing picklable partial, which evaluates f(1 - x).

cm = Colormap("prism")
cm.color_stops.lut_func(np.array([0.1234]))  # exact, not LUT-sampled

Also corrects the lut_func parameter docs: the callable receives an (N,) array (it is called with np.linspace), not (N, 1), and may return RGB or RGBA.

🤖 Generated with Claude Code

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

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.95%. Comparing base (f0a4aec) to head (31f130d).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: make exact evaluation of function-defined colormaps accessible

1 participant