fix: import scanpy default palettes across scanpy versions (1.13 compat) - #759
Merged
Conversation
scanpy 1.13 relocated default_20/default_28/default_102 from scanpy.plotting.palettes to scanpy.plotting.legacy.palettes, breaking `import spatialdata_plot` on pre-release scanpy (every test in the py3.14-pre env errored at conftest collection). Centralize the three duplicated imports into a single _scanpy_palettes shim that tries the new path and falls back to the old one, and point _palette.py, _color.py and utils.py at it. The palette values are frozen (identical across scanpy versions), so behavior is unchanged.
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.
Problem
The
py3.14-preCI env installs pre-release scanpy 1.13.0a1, whereimport spatialdata_plotcrashes at collection:Every test in that env errors at
conftest.pyimport.Root cause
scanpy 1.13 relocated the default categorical palettes from
scanpy.plotting.palettestoscanpy.plotting.legacy.palettes(no survivingsc.pl.palettesalias). spatialdata-plot imported the old path in three modules (_palette.py,_color.py,utils.py).Fix
Add a single
_scanpy_palettesshim that imports from the new path and falls back to the old one, and point all three modules at it:The palette values are frozen —
default_20/28/102hash identically across scanpy 1.11.4 and 1.13.0a1 — so behavior is unchanged; this only makes the import resilient to the relocation.Verification
import spatialdata_plotsucceeds;test_palette.py(41) green locally.Notes
py3.14-preiscontinue-on-error(non-gating), so this is a forward-looking fix for scanpy 1.13 readiness rather than a merge blocker.