Skip to content

Fix double .compute() when render_points color= is a native column#643

Merged
timtreis merged 4 commits intomainfrom
fix/issue-633-points-double-compute
May 8, 2026
Merged

Fix double .compute() when render_points color= is a native column#643
timtreis merged 4 commits intomainfrom
fix/issue-633-points-double-compute

Conversation

@timtreis
Copy link
Copy Markdown
Member

@timtreis timtreis commented May 8, 2026

Summary

  • render_points(color=<native_col>) was calling dd.DataFrame.compute() twice: once explicitly to load the points (render.py:747) and again inside _set_color_source_vec via a redundant get_values() call (utils.py:1077).
  • Root cause: the _preloaded shortcut only fired when added_color_from_table=True. For element-native color columns the flag stayed False, so _set_color_source_vec fell back to a fresh get_values() call.
  • Fix: widen the condition to col_for_color is not None and col_for_color in points_pd_with_color.columns, which is True for both native-column and table-sourced cases.

Closes #633.

Test plan

  • test_render_points_native_color_column_single_compute — patches dd.DataFrame.compute to count calls and asserts exactly 1 for a native categorical color column

timtreis and others added 2 commits May 7, 2026 22:36
)

The _preloaded optimisation previously only fired when color data came from
an AnnData table (added_color_from_table=True). For element-native color
columns the flag stayed False, so _set_color_source_vec fell back to a
fresh get_values() call — a second .compute() on the dask DataFrame.

Fix: widen the condition to col_for_color in points_pd_with_color.columns,
which is True in both the native-column and table-sourced cases.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@timtreis timtreis changed the title Fix double .compute() when render_points color= is a native column (#633) Fix double .compute() when render_points color= is a native column May 8, 2026
timtreis and others added 2 commits May 8, 2026 12:13
…text()

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 Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.39%. Comparing base (e1f8863) to head (75434d6).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #643   +/-   ##
=======================================
  Coverage   76.39%   76.39%           
=======================================
  Files          11       11           
  Lines        3237     3237           
  Branches      759      761    +2     
=======================================
  Hits         2473     2473           
  Misses        466      466           
  Partials      298      298           
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/render.py 86.67% <100.00%> (+0.08%) ⬆️

... 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 072f04e into main May 8, 2026
7 of 8 checks passed
@timtreis timtreis deleted the fix/issue-633-points-double-compute branch May 8, 2026 10: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.

render_points materialises dask DataFrame twice when color= is a points column

2 participants