Skip to content

Reject NaN pixels in render_images#673

Merged
timtreis merged 2 commits into
mainfrom
fix/issue-628
May 20, 2026
Merged

Reject NaN pixels in render_images#673
timtreis merged 2 commits into
mainfrom
fix/issue-628

Conversation

@timtreis
Copy link
Copy Markdown
Member

@timtreis timtreis commented May 20, 2026

Summary

  • render_images previously had asymmetric, silent NaN handling: single-channel substituted na_color via cmap.set_bad, multi-channel additively composited NaN as opaque black through per-channel cmaps that did not carry set_bad. Both paths hid upstream data issues (stitched gaps, padded crops, masked tissue, segmentation outputs).
  • Both paths now raise ValueError early in _render_images with the element name, offending channel(s), and a fillna(...) hint.
  • Integer-dtype channels are skipped (cannot contain NaN) by gating the check on np.issubdtype(layer.dtype, np.floating) before materializing, so uint8/uint16 microscopy images pay no cost.

Closes #628

Single-channel silently substituted na_color via cmap.set_bad; multi-channel
silently composited NaN as black via additive per-channel cmaps without
set_bad. Both paths now raise ValueError listing the offending channels and
pointing to fillna().
@timtreis timtreis changed the title Reject NaN pixels in render_images (#628) Reject NaN pixels in render_images May 20, 2026
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.66%. Comparing base (59da170) to head (08d9bbd).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #673      +/-   ##
==========================================
+ Coverage   77.63%   77.66%   +0.03%     
==========================================
  Files          11       11              
  Lines        3612     3626      +14     
  Branches      850      856       +6     
==========================================
+ Hits         2804     2816      +12     
  Misses        485      485              
- Partials      323      325       +2     
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/render.py 87.10% <100.00%> (+0.12%) ⬆️

... and 2 files with indirect coverage changes

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

@timtreis timtreis merged commit 53421a5 into main May 20, 2026
7 of 8 checks passed
@timtreis timtreis deleted the fix/issue-628 branch May 20, 2026 14:24
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.

NaN pixels in multi-channel images silently render black instead of na_color

2 participants