Skip to content

fix(datashader): handle zero-extent point sets instead of NaN canvas#728

Merged
timtreis merged 1 commit into
mainfrom
fix/issue-724
Jun 20, 2026
Merged

fix(datashader): handle zero-extent point sets instead of NaN canvas#728
timtreis merged 1 commit into
mainfrom
fix/issue-724

Conversation

@timtreis

@timtreis timtreis commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #724. render_points(method="datashader") on a single point (or coincident points, or an axis-aligned line) crashed with ValueError: cannot convert float NaN to integer.

…724)

A single point (or coincident points / an axis-aligned line) has zero spatial
extent, so _compute_datashader_canvas_params computed factor=0 and then
int(round(width / 0)) raised 'cannot convert float NaN to integer'.

Pad any degenerate axis to a unit window centered on its value before deriving
the canvas scale, so the data lands in a finite canvas and renders. Non-degenerate
extents are passed through unchanged, so normal data is unaffected.

Fixes #724.
@timtreis timtreis changed the title fix(datashader): handle zero-extent point sets instead of NaN canvas (#724) fix(datashader): handle zero-extent point sets instead of NaN canvas Jun 20, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.21%. Comparing base (0919069) to head (efcec6d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #728      +/-   ##
==========================================
+ Coverage   79.20%   79.21%   +0.01%     
==========================================
  Files          17       17              
  Lines        4563     4566       +3     
  Branches     1026     1026              
==========================================
+ Hits         3614     3617       +3     
  Misses        599      599              
  Partials      350      350              
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/_datashader.py 87.53% <100.00%> (+0.10%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timtreis timtreis merged commit 480d9f0 into main Jun 20, 2026
7 of 8 checks passed
@timtreis timtreis deleted the fix/issue-724 branch June 20, 2026 13:04
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 backend crashes on a single point (zero extent → NaN canvas size)

2 participants