perf(shapes): vectorize datashader polygon scaling#740
Merged
Conversation
Re-lands #738 (accidentally merged then reverted in #739), with the code-review cleanups applied: the helper lives in _geometry.py next to its matplotlib-Path twin _scale_path_around_centroid (module-level shapely import, no local one). The datashader path scaled polygons with a per-geometry affinity.scale loop — a pure-Python loop that dominates large polygon renders (~60% of a 100k-polygon render). _scale_geometries scales every coordinate about each geometry's bounding-box centre (affinity.scale's default origin) in one vectorized get_coordinates/set_coordinates pass. Byte-identical to affinity.scale incl. asymmetric shapes, multipolygons and holes (verified main-vs-branch diff_px=0; unit test at 1e-9); ~12x polygons / ~6.5x multipolygons. Only fires for scale != 1.0.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #740 +/- ##
==========================================
+ Coverage 79.29% 79.33% +0.03%
==========================================
Files 17 17
Lines 4599 4603 +4
Branches 1030 1030
==========================================
+ Hits 3647 3652 +5
Misses 602 602
+ Partials 350 349 -1
🚀 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.
Vectorize datashader polygon/multipolygon scaling: the old per-geometry
affinity.scaleloop is pure Python and dominates large renders (~60% of a 100k-polygon render)._scale_geometriesscales all coordinates about each geometry's bounding-box centre (affinity.scale's default origin) in oneget_coordinates/set_coordinatespass. Only fires forscale != 1.0.Byte-identical to
affinity.scale(asymmetric shapes, multipolygons, holes; main-vs-branch render diff_px=0). Trades peak memory for speed (scale=0.6):Re-land of #738 (reverted in #739); helper lives in
_geometry.pynext to_scale_path_around_centroid.