Skip to content

Fix datashader fill_alpha applied twice#552

Merged
timtreis merged 4 commits intomainfrom
fix/issue-367-double-alpha
Mar 20, 2026
Merged

Fix datashader fill_alpha applied twice#552
timtreis merged 4 commits intomainfrom
fix/issue-367-double-alpha

Conversation

@timtreis
Copy link
Member

@timtreis timtreis commented Mar 20, 2026

Summary

  • Fixes Datashader shapes outlines and fill_alpha documentation #367: datashader fill_alpha (and alpha for points, outline_alpha for outlines) was applied twice — once in ds.tf.shade(min_alpha=...) baking it into the RGBA image, then again in ax.imshow(alpha=...) multiplying the alpha channel a second time
  • Effective transparency was fill_alpha² instead of fill_alpha (e.g., 0.25 instead of 0.5), making datashader elements appear lighter than their matplotlib equivalents
  • Fix: remove the second alpha application in _render_ds_image() and _render_ds_outlines(), since the RGBA channels from datashader already encode transparency correctly

timtreis and others added 2 commits March 20, 2026 17:28
Alpha was passed both to ds.tf.shade(min_alpha=...) and to
ax.imshow(alpha=...), resulting in effective transparency of
fill_alpha² instead of fill_alpha. Remove the second application
since the RGBA channels from datashader already encode transparency.

Affects shapes (fill_alpha), points (alpha), and shape outlines
(outline_alpha).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Regenerated from CI after fixing the double-alpha bug (#367).
Only 2 tests exceeded the RMS tolerance; the rest were within bounds.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@timtreis timtreis force-pushed the fix/issue-367-double-alpha branch from 03426f8 to b856ae0 Compare March 20, 2026 16:39
timtreis and others added 2 commits March 20, 2026 17:44
- Add regression test for outline_alpha double-application
- Make points test docstring consistent with shapes test
- Replace :issue:`367` with plain #367 (no Sphinx role configured)
- Remove redundant inline comment in shapes test

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Exercises both code paths (_render_ds_image and _render_ds_outlines)
in a single render call, halving the test cost.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@timtreis timtreis marked this pull request as ready for review March 20, 2026 16:54
@timtreis timtreis merged commit 886f484 into main Mar 20, 2026
8 checks passed
@timtreis timtreis deleted the fix/issue-367-double-alpha branch March 20, 2026 16:54
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.66%. Comparing base (61ed9c3) to head (c643ddc).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #552   +/-   ##
=======================================
  Coverage   73.66%   73.66%           
=======================================
  Files          10       10           
  Lines        2738     2738           
  Branches      637      637           
=======================================
  Hits         2017     2017           
  Misses        447      447           
  Partials      274      274           
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/_datashader.py 91.91% <100.00%> (ø)
src/spatialdata_plot/pl/render.py 81.87% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Datashader shapes outlines and fill_alpha documentation

2 participants