|
44 | 44 | resolve_color, |
45 | 45 | ) |
46 | 46 | from spatialdata_plot.pl._datashader import ( |
| 47 | + _affine_major_scale, |
47 | 48 | _ax_show_and_transform, |
48 | 49 | _build_ds_colorbar, |
49 | 50 | _circle_buffer_quad_segs, |
@@ -592,7 +593,7 @@ def _circles_render_as_points(shapes: gpd.GeoDataFrame, is_point: Any, render_pa |
592 | 593 | or len(shapes) <= _CIRCLE_FAST_PATH_MIN |
593 | 594 | or render_params.outline_alpha[0] > 0 |
594 | 595 | or render_params.outline_alpha[1] > 0 |
595 | | - or not bool(is_point.all()) |
| 596 | + or not is_point.all() |
596 | 597 | ): |
597 | 598 | return False |
598 | 599 | radius = pd.to_numeric(shapes["radius"], errors="coerce").to_numpy() |
@@ -765,7 +766,6 @@ def _draw_centroids(xy: np.ndarray, radius: float | None = None) -> None: |
765 | 766 | ) |
766 | 767 |
|
767 | 768 | if render_params.as_points: |
768 | | - # Fast mode: draw one dot per shape at its centroid instead of its geometry. |
769 | 769 | logger.info("`as_points=True`: rendering shape centroids; `outline_*` and `shape` are ignored.") |
770 | 770 | centroids = shapes.geometry.centroid # intrinsic; transform so dots land under non-identity transforms |
771 | 771 | _draw_centroids(trans.transform(np.column_stack([centroids.x.to_numpy(), centroids.y.to_numpy()]))) |
@@ -806,8 +806,9 @@ def _draw_centroids(xy: np.ndarray, radius: float | None = None) -> None: |
806 | 806 | # pixel) the same as spread points, skipping the per-circle buffer/polygon-aggregation cost. |
807 | 807 | if _circles_render_as_points(shapes, is_point, render_params): |
808 | 808 | logger.info(f"Rendering {len(shapes)} uniform circles as datashader points (fast path).") |
809 | | - stretch = float(np.linalg.svd(tm[:2, :2], compute_uv=False).max()) # circle radius in CS units |
810 | | - radius_cs = float(pd.to_numeric(shapes["radius"], errors="coerce").iloc[0]) * render_params.scale * stretch |
| 809 | + # radius is gate-guaranteed uniform + finite, so coerce only the first value (avoids an O(n) pass). |
| 810 | + radius_one = float(pd.to_numeric(shapes["radius"].iloc[:1], errors="coerce").iloc[0]) |
| 811 | + radius_cs = radius_one * render_params.scale * _affine_major_scale(tm) |
811 | 812 | xy = trans.transform(np.column_stack([_geometry.x.to_numpy(), _geometry.y.to_numpy()])) |
812 | 813 | _draw_centroids(xy, radius=radius_cs) |
813 | 814 | return |
|
0 commit comments