Skip to content

Commit f08a03e

Browse files
[pre-commit.ci] pre-commit autoupdate (#997)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.7.2 → v0.7.3](astral-sh/ruff-pre-commit@v0.7.2...v0.7.3) * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.1 → v0.9.1](astral-sh/ruff-pre-commit@v0.8.1...v0.9.1) - [github.com/pre-commit/mirrors-mypy: v1.13.0 → v1.14.1](pre-commit/mirrors-mypy@v1.13.0...v1.14.1) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixed mypy * copied upper limited for dask from sdata * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.3 → v0.9.6](astral-sh/ruff-pre-commit@v0.9.3...v0.9.6) - [github.com/pre-commit/mirrors-mypy: v1.14.1 → v1.15.0](pre-commit/mirrors-mypy@v1.14.1...v1.15.0) * mypy fixes * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/rbubley/mirrors-prettier: v3.5.3 → v3.6.2](rbubley/mirrors-prettier@v3.5.3...v3.6.2) - [github.com/astral-sh/ruff-pre-commit: v0.11.7 → v0.14.1](astral-sh/ruff-pre-commit@v0.11.7...v0.14.1) - [github.com/pre-commit/mirrors-mypy: v1.15.0 → v1.18.2](pre-commit/mirrors-mypy@v1.15.0...v1.18.2) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * mypy fix * mypy fix --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tim Treis <[email protected]> Co-authored-by: Tim Treis <[email protected]> Co-authored-by: Tim Treis <[email protected]>
1 parent 900d7b3 commit f08a03e

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,24 @@ default_stages:
77
minimum_pre_commit_version: 2.16.0
88
repos:
99
- repo: https://github.com/rbubley/mirrors-prettier
10-
rev: v3.5.3
10+
rev: v3.6.2
1111
hooks:
1212
- id: prettier
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.11.7
14+
rev: v0.14.1
1515
hooks:
1616
- id: ruff
1717
types_or: [python, pyi, jupyter]
1818
args: [--fix, --exit-non-zero-on-fix]
1919
- id: ruff-format
2020
types_or: [python, pyi, jupyter]
21+
- repo: https://github.com/asottile/blacken-docs
22+
rev: 1.19.1
23+
hooks:
24+
- id: blacken-docs
2125
- repo: https://github.com/pre-commit/mirrors-mypy
22-
rev: v1.15.0
26+
rev: v1.18.2
2327
hooks:
2428
- id: mypy
25-
additional_dependencies: [numpy, types-requests]
26-
exclude: tests/|docs/
29+
additional_dependencies: [numpy, pandas, types-requests]
30+
exclude: tests/|docs/|.scripts/ci/download_data.py|squidpy/datasets/_(dataset|image).py

src/squidpy/pl/_interactive/_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _set_library(self) -> None:
102102
self.library_id = [self.library_id]
103103
self.library_id, _ = _unique_order_preserving(self.library_id) # type: ignore[assignment]
104104

105-
if not len(self.library_id):
105+
if self.library_id is None or not len(self.library_id):
106106
raise ValueError("No library ids have been selected.")
107107
# invalid library ids from adata are filtered below
108108
# invalid library ids from container raise KeyError in `__post_init__` after this call

src/squidpy/pl/_spatial_utils.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from functools import partial
77
from numbers import Number
88
from types import MappingProxyType
9-
from typing import TYPE_CHECKING, Any, Literal, NamedTuple, Optional, TypeAlias, Union
9+
from typing import TYPE_CHECKING, Any, Literal, NamedTuple, TypeAlias, cast
1010

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

844844
# set cmap and norm
845+
845846
if cmap is None:
846-
cmap = plt.rcParams["image.cmap"]
847-
if isinstance(cmap, str):
848-
cmap = plt.colormaps[cmap]
849-
cmap.set_bad("lightgray" if na_color is None else na_color)
847+
cmap_name: str = str(plt.rcParams["image.cmap"])
848+
cmap_obj = plt.get_cmap(cmap_name)
849+
elif isinstance(cmap, str):
850+
cmap_obj = plt.get_cmap(cmap)
851+
else:
852+
cmap_obj = cmap # already a Colormap
853+
854+
cmap_obj.set_bad("lightgray" if na_color is None else na_color)
850855

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

865871
fig_params = FigParams(fig, ax, axs, iter_panels, title, ax_labels, frameon)
866-
cmap_params = CmapParams(cmap, img_cmap, norm)
872+
cmap_params = CmapParams(cmap_obj, img_cmap, norm)
867873
scalebar_params = ScalebarParams(scalebar_dx, scalebar_units)
868874

869875
return fig_params, cmap_params, scalebar_params, kwargs

0 commit comments

Comments
 (0)