You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Refactor: split utils.py (4454 lines) into _validate.py / _color.py / _geometry.py and finish _datashader.py extraction #696
src/spatialdata_plot/pl/utils.py is 4454 lines and mixes several unrelated concerns. Roughly ~3400 of those lines are two cohesive concerns (validation, color resolution) interleaved with everything else. Splitting them into sibling modules would massively improve navigability and shrink the blast radius of changes — with essentially no behavioral risk.
Why now
Any contributor touching one validation message or color helper must scroll a 4454-line file and risks editing adjacent unrelated code.
There is no import cycle in the extraction direction: utils.py imports only from render_params (a leaf) plus third-party libs — never from render.py/basic.py. The consumers import from utils.
There is an established precedent: pl/_palette.py and pl/_datashader.py are already self-contained sibling modules.
All symbols involved are private (_foo) — no public API surface to preserve.
the canvas/aggregate helpers still in utils.py (L3910–4451) that _datashader.py currently back-imports — the only near-cycle in the repo. Also fixes the _datshader_get_how_kw_for_spread typo.
After these moves, utils.py is left as a ~1000-line grab-bag of genuinely cross-cutting helpers (figure/axes, coord/extent, table extraction).
Risk / effort
Mechanical: each move is an import-path swap in render.py/basic.py/_datashader.py (their import blocks already group symbols by concern). No cycle, no public surface, covered by existing tests. Effort: medium · Risk: low. Best done as one module per PR.
Notes
The two mega-functions being relocated (_get_collection_shape, _convert_shapes, _type_check_params, _set_color_source_vec) are themselves decomposition candidates, but that is out of scope here — this issue is the relocation only, to keep diffs reviewable. Decomposition can follow once each lives in a smaller, single-concern file.
Activity
refactor(utils): extract color resolution into _color.py (#696)
refactor(utils): extract parameter validation into _validate.py (#696)
refactor(utils): move 6 cross-cutting helpers from _color to utils (#696
fix(utils): keep set_zero_in_cmap_to_transparent public