Skip to content

Fix docstrings and remove dead code across public API#583

Merged
timtreis merged 3 commits intomainfrom
fix/issue-463-docstring-audit
Apr 6, 2026
Merged

Fix docstrings and remove dead code across public API#583
timtreis merged 3 commits intomainfrom
fix/issue-463-docstring-audit

Conversation

@timtreis
Copy link
Copy Markdown
Member

@timtreis timtreis commented Apr 6, 2026

Summary

  • Systematic audit of all public method docstrings against their implementations
  • Fix 17+ docstring mismatches (wrong types, wrong defaults, copy-paste errors, missing params)
  • Remove dead/broken code: share_extent, render_images(**kwargs), render_images(na_color=...), dead transfunc in labels, vestigial dataclass fields
  • Warn on colorbar=True for 5+ channel images

Docstring fixes

Fix Methods
norm type/default (bool | Normalize, default FalseNormalize | None) render_shapes, render_points
palette type: add dict[str, str] render_shapes, render_points, render_labels
Remove false palette+groups default claim render_shapes, render_points, render_labels
cmap: "discrete or continuous" → continuous only render_shapes, render_points
scale: "circles" → "shapes (circles and polygons)" render_shapes
method: "and" → "or", add >10k threshold render_shapes, render_points
show() return type: sd.SpatialDataAxes | list[Axes] | None show
Document all 13 missing show() parameters show
render_labels return type: Nonesd.SpatialData render_labels
render_points return: "shapes" → "points" render_points
Add RGB auto-detection + compositing Notes render_images
Add colorbar/colorbar_params type annotations all render methods
Fix make_palette_from_data color lookup description _palette.py
Fix OutlineParams docstring copy-paste render_params.py

Dead code removal

What Why
show(share_extent=...) Accepted, validated, documented — but never used. No code shares extent across panels.
render_images(na_color=...) Images never contain NaN pixels; set_bad() never triggers.
render_images(**kwargs) Broken: scalar-cmap path passes kwargs to _prepare_cmap_norm() which doesn't accept them (would crash). vmin/vmax deprecated 18 months ago.
LabelsRenderParams.transfunc Stored but _render_labels() never reads it. Filed #582 for the broader transfunc inconsistency.
LabelsRenderParams.outline Vestigial bool, always False, never set or read.
ShapesRenderParams.contour_px Only relevant for labels, dead weight on shapes dataclass.

timtreis and others added 3 commits April 6, 2026 12:25
Systematic audit of all public method docstrings against their
implementations, fixing mismatches and removing dead/broken code.

Docstring fixes:
- Fix `norm` type/default in render_shapes, render_points (was `bool | Normalize, default False`, now `Normalize | None`)
- Fix `palette` type across all render methods (add `dict[str, str]`)
- Remove false claim that palette defaults to lightgray when groups given
- Fix `cmap` description: continuous only, not discrete (render_shapes, render_points)
- Fix `scale` description in render_shapes: applies to polygons too
- Fix `method` description: "or" not "and", add >10k threshold
- Fix `show()` return type: `Axes | list[Axes] | None`, not `sd.SpatialData`
- Document all 13 missing `show()` parameters
- Fix `render_labels` return type (was `None`)
- Fix `render_points` return saying "shapes" (copy-paste)
- Fix `render_labels` broadcasting example referencing render_images
- Add Notes section to render_images: RGB auto-detection, compositing, cmap broadcast
- Add type annotations to colorbar/colorbar_params across all methods
- Fix `make_palette_from_data` color column lookup description
- Fix OutlineParams docstring (was "Cmap params")
- Fix typo "precendence" → "precedence"

Dead code removal:
- Remove `share_extent` from `show()` (accepted but never used)
- Remove `na_color` from `render_images()` (no use case for images)
- Remove `**kwargs` from `render_images()` (broken: crashed or was silently dropped)
- Remove dead `transfunc` from `LabelsRenderParams` (stored but never read)
- Remove vestigial `LabelsRenderParams.outline` field
- Remove vestigial `ShapesRenderParams.contour_px` field

New behavior:
- Warn when user requests `colorbar=True` for 5+ channel images

Related: #463, #582

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Change 5+ channel colorbar message to logger.info on auto mode only
  (explicit colorbar=True is not blocked)
- Fix double periods in dataclass docstrings

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Align render_labels cmap/norm docstrings with shapes/points style
- Remove misleading kwargs docstring entry from render_labels
- Guard na_color processing in _type_check_params to skip images

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.33%. Comparing base (7817c38) to head (964ae9a).

Files with missing lines Patch % Lines
src/spatialdata_plot/pl/render.py 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #583      +/-   ##
==========================================
+ Coverage   76.28%   76.33%   +0.05%     
==========================================
  Files          11       11              
  Lines        3259     3254       -5     
  Branches      756      756              
==========================================
- Hits         2486     2484       -2     
+ Misses        468      467       -1     
+ Partials      305      303       -2     
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/_palette.py 85.08% <ø> (ø)
src/spatialdata_plot/pl/basic.py 85.35% <ø> (+0.54%) ⬆️
src/spatialdata_plot/pl/render_params.py 86.29% <ø> (-0.21%) ⬇️
src/spatialdata_plot/pl/utils.py 66.25% <100.00%> (+0.14%) ⬆️
src/spatialdata_plot/pl/render.py 86.42% <0.00%> (-0.28%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timtreis timtreis merged commit db82da8 into main Apr 6, 2026
8 checks passed
@timtreis timtreis deleted the fix/issue-463-docstring-audit branch April 6, 2026 10:42
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.

2 participants