Fix double .compute() when render_points color= is a native column#643
Merged
Fix double .compute() when render_points color= is a native column#643
Conversation
) 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>
…text() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
render_points(color=<native_col>)was callingdd.DataFrame.compute()twice: once explicitly to load the points (render.py:747) and again inside_set_color_source_vecvia a redundantget_values()call (utils.py:1077)._preloadedshortcut only fired whenadded_color_from_table=True. For element-native color columns the flag stayedFalse, so_set_color_source_vecfell back to a freshget_values()call.col_for_color is not None and col_for_color in points_pd_with_color.columns, which isTruefor both native-column and table-sourced cases.Closes #633.
Test plan
test_render_points_native_color_column_single_compute— patchesdd.DataFrame.computeto count calls and asserts exactly 1 for a native categorical color column