Skip to content

Render constant-value channels as mid-grey with a warning#636

Merged
timtreis merged 12 commits intomainfrom
fix/issue-598-uniform-channel-black
Apr 24, 2026
Merged

Render constant-value channels as mid-grey with a warning#636
timtreis merged 12 commits intomainfrom
fix/issue-598-uniform-channel-black

Conversation

@timtreis
Copy link
Copy Markdown
Member

@timtreis timtreis commented Apr 24, 2026

Summary

  • A channel where all pixel values are identical causes Normalize to compute 0/0, silently producing an all-black composite with no error or warning
  • Before normalization, check if the channel is constant (min == max) and no explicit vmin/vmax was provided; if so, substitute 0.5 and emit a logger.warning
  • This makes the channel visible (mid-grey) and informs the user their data has no contrast in that channel

Fixes #598.

timtreis and others added 2 commits April 24, 2026 18:34
A channel whose min == max causes Normalize to compute 0/0, silently
producing an all-zero (black) composite. Detect this before normalization
and substitute 0.5 so the channel remains visible, emitting a logger
warning so the user knows their data has no contrast.

The guard is skipped when the user supplies explicit vmin/vmax on the norm.

Fixes #598.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.41%. Comparing base (9afec7e) to head (e92b734).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #636   +/-   ##
=======================================
  Coverage   76.40%   76.41%           
=======================================
  Files          11       11           
  Lines        3230     3235    +5     
  Branches      758      759    +1     
=======================================
+ Hits         2468     2472    +4     
  Misses        464      464           
- Partials      298      299    +1     
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/render.py 86.59% <100.00%> (+0.10%) ⬆️

... and 1 file with indirect coverage changes

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

timtreis and others added 5 commits April 24, 2026 19:16
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove custom logging handler infrastructure; check only that pixel
values are non-zero.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The channel maps through viridis (mid-value, not mid-grey); update
title and docstring accordingly. Drop stale reference image so CI
regenerates it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
timtreis and others added 5 commits April 24, 2026 20:04
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@timtreis timtreis merged commit f3e13b8 into main Apr 24, 2026
8 checks passed
@timtreis timtreis deleted the fix/issue-598-uniform-channel-black branch April 24, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-channel image: uniform (constant) channels render silently black with no warning

2 participants