Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@ default_stages:
minimum_pre_commit_version: 2.16.0
repos:
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.5.3
rev: v3.6.2
hooks:
- id: prettier
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.7
rev: v0.14.1
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
types_or: [python, pyi, jupyter]
- repo: https://github.com/asottile/blacken-docs
rev: 1.19.1
hooks:
- id: blacken-docs
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.15.0
rev: v1.18.2
hooks:
- id: mypy
additional_dependencies: [numpy, types-requests]
exclude: tests/|docs/
additional_dependencies: [numpy, pandas, types-requests]
exclude: tests/|docs/|.scripts/ci/download_data.py|squidpy/datasets/_(dataset|image).py
2 changes: 1 addition & 1 deletion src/squidpy/pl/_interactive/_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _set_library(self) -> None:
self.library_id = [self.library_id]
self.library_id, _ = _unique_order_preserving(self.library_id) # type: ignore[assignment]

if not len(self.library_id):
if self.library_id is None or not len(self.library_id):
raise ValueError("No library ids have been selected.")
# invalid library ids from adata are filtered below
# invalid library ids from container raise KeyError in `__post_init__` after this call
Expand Down
18 changes: 12 additions & 6 deletions src/squidpy/pl/_spatial_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from functools import partial
from numbers import Number
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, Literal, NamedTuple, Optional, TypeAlias, Union
from typing import TYPE_CHECKING, Any, Literal, NamedTuple, TypeAlias, cast

import dask.array as da
import numpy as np
Expand Down Expand Up @@ -842,12 +842,18 @@ def _prepare_params_plot(
fig, ax = plt.subplots(figsize=figsize, dpi=dpi, constrained_layout=True)

# set cmap and norm

if cmap is None:
cmap = plt.rcParams["image.cmap"]
if isinstance(cmap, str):
cmap = plt.colormaps[cmap]
cmap.set_bad("lightgray" if na_color is None else na_color)
cmap_name: str = str(plt.rcParams["image.cmap"])
cmap_obj = plt.get_cmap(cmap_name)
elif isinstance(cmap, str):
cmap_obj = plt.get_cmap(cmap)
else:
cmap_obj = cmap # already a Colormap

cmap_obj.set_bad("lightgray" if na_color is None else na_color)

# build norm as before...
if isinstance(norm, Normalize):
pass
elif vcenter is None:
Expand All @@ -863,7 +869,7 @@ def _prepare_params_plot(
scalebar_dx, scalebar_units = _get_scalebar(scalebar_dx, scalebar_units, len(spatial_params.library_id))

fig_params = FigParams(fig, ax, axs, iter_panels, title, ax_labels, frameon)
cmap_params = CmapParams(cmap, img_cmap, norm)
cmap_params = CmapParams(cmap_obj, img_cmap, norm)
scalebar_params = ScalebarParams(scalebar_dx, scalebar_units)

return fig_params, cmap_params, scalebar_params, kwargs
Expand Down