Skip to content

fix: full scanpy 1.13 compatibility layer - #760

Merged
timtreis merged 1 commit into
mainfrom
fix/scanpy113-compat
Aug 7, 2026
Merged

fix: full scanpy 1.13 compatibility layer#760
timtreis merged 1 commit into
mainfrom
fix/scanpy113-compat

Conversation

@timtreis

@timtreis timtreis commented Aug 7, 2026

Copy link
Copy Markdown
Member

Goal

Make spatialdata-plot fully compatible with scanpy 1.13 (the pre-release used in the py3.14-pre CI env), which reorganized its plotting internals and broke import spatialdata_plot and several render paths.

Complete scanpy-internal surface (audited across src/)

Symbol scanpy 1.13 change Handling
default_20/28/102 plotting.palettesplotting.legacy.palettes import with fallback
_add_categorical_legend plotting._tools.scatterplotsplotting.legacy._tools... import with fallback
add_colors_for_categorical_sample_annotation plotting._utilsplotting.legacy._utils import with fallback
settings._vector_friendly removed vector_friendly() helper, defaults to False, still honours sc.set_figure_params on older scanpy
sc.get.obs_df, settings.figdir, sc.set_figure_params, sc.pl.set_rcParams_defaults unchanged used directly, no change

All of it is consolidated into one version-tolerant module, _scanpy_compat, and every call site (render.py, utils.py, _color.py, _palette.py) routes through it — so the reliance on scanpy internals lives in exactly one place.

Why behaviour is unchanged

The relocated palettes/helpers are frozen copies: default_* hash identically across 1.11.4 and 1.13.0a1, and _add_categorical_legend / add_colors_... have identical signatures in the old and legacy locations. vector_friendly() reproduces scanpy's historical default.

Verification

  • Symbols resolve on stable scanpy 1.11.4 (fallback) and pre-release 1.13.0a1 (new path).
  • Resolved against scanpy 1.13.0a1, the full non-visual suite passes and there are zero scanpy AttributeError/ImportError (visual test_plot_* only run on the GH runner). CI's py3.14-pre is the authoritative visual check.

Notes

Follow-up to the merged #759 (palettes-only). py3.14-pre is continue-on-error (non-gating); this is scanpy-1.13 readiness.

@timtreis
timtreis force-pushed the fix/scanpy113-compat branch from 6d18fa7 to e62e952 Compare August 7, 2026 13:56
@timtreis timtreis changed the title fix: tolerate scanpy 1.13 relocation of internal plotting helpers fix: tolerate scanpy 1.13 relocation of _tools/_utils plotting helpers Aug 7, 2026
@timtreis
timtreis force-pushed the fix/scanpy113-compat branch from e62e952 to 06c2c0d Compare August 7, 2026 14:04
@codecov-commenter

codecov-commenter commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.63%. Comparing base (5627c9b) to head (ce185c0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #760      +/-   ##
==========================================
+ Coverage   79.60%   79.63%   +0.03%     
==========================================
  Files          18       18              
  Lines        4657     4665       +8     
  Branches     1032     1032              
==========================================
+ Hits         3707     3715       +8     
  Misses        599      599              
  Partials      351      351              
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/_color.py 70.03% <100.00%> (-0.05%) ⬇️
src/spatialdata_plot/pl/_palette.py 85.31% <100.00%> (ø)
src/spatialdata_plot/pl/_scanpy_compat.py 100.00% <100.00%> (ø)
src/spatialdata_plot/pl/render.py 89.40% <100.00%> (-0.02%) ⬇️
src/spatialdata_plot/pl/utils.py 78.97% <100.00%> (-0.04%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timtreis
timtreis force-pushed the fix/scanpy113-compat branch from 06c2c0d to 28c7142 Compare August 7, 2026 14:24
@timtreis timtreis changed the title fix: tolerate scanpy 1.13 relocation of _tools/_utils plotting helpers fix: full scanpy 1.13 compatibility layer Aug 7, 2026
@timtreis timtreis closed this Aug 7, 2026
@timtreis timtreis reopened this Aug 7, 2026
@timtreis
timtreis force-pushed the fix/scanpy113-compat branch 2 times, most recently from 18069cb to 51e49a8 Compare August 7, 2026 14:34
scanpy 1.13 reorganized its plotting internals, breaking spatialdata-plot
on pre-release scanpy. Consolidate every reliance on scanpy internals into
one version-tolerant module, _scanpy_compat, that imports each symbol from
the new location with a fallback to the old:

- palettes default_20/28/102        scanpy.plotting.palettes    -> .legacy.palettes
- _add_categorical_legend           scanpy.plotting._tools...   -> .legacy._tools...
- add_colors_for_categorical_...    scanpy.plotting._utils      -> .legacy._utils
- vector_friendly()                 settings._vector_friendly removed in 1.13; default False

Route all src call sites (render.py, utils.py, _color.py, _palette.py) and
the one test that referenced scanpy's palette module (test_palette.py)
through _scanpy_compat. The settings import uses the stable public
`from scanpy import settings`, and the fallbacks catch ModuleNotFoundError
(not the broader ImportError) so a broken-but-present legacy module surfaces
instead of being silently masked.

Behaviour is unchanged: relocated palettes/helpers are frozen copies
(identical values and signatures). vector_friendly() keeps honouring
sc.set_figure_params on older scanpy and defaults to False on >=1.13 where
the flag no longer exists.

Verified: passes on scanpy 1.11.4 (fallback) and 1.13.0a1 (legacy path);
CI py3.14-pre is green (882 passed).
@timtreis
timtreis force-pushed the fix/scanpy113-compat branch from 51e49a8 to ce185c0 Compare August 7, 2026 15:04
@timtreis
timtreis merged commit e9b3122 into main Aug 7, 2026
8 checks passed
@timtreis
timtreis deleted the fix/scanpy113-compat branch August 7, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants