Skip to content

Commit 5c9b8ae

Browse files
[pre-commit.ci] pre-commit autoupdate (#854)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/pre-commit/mirrors-mypy: v1.10.1 → v1.11.0](pre-commit/mirrors-mypy@v1.10.1...v1.11.0) - [github.com/astral-sh/ruff-pre-commit: v0.5.2 → v0.5.4](astral-sh/ruff-pre-commit@v0.5.2...v0.5.4) * fix mypy --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: giovp <[email protected]>
1 parent 39f0954 commit 5c9b8ae

File tree

2 files changed

+48
-13
lines changed

2 files changed

+48
-13
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ default_stages:
77
minimum_pre_commit_version: 2.9.3
88
repos:
99
- repo: https://github.com/pre-commit/mirrors-mypy
10-
rev: v1.10.1
10+
rev: v1.11.0
1111
hooks:
1212
- id: mypy
1313
additional_dependencies: [numpy, pandas, types-requests]
@@ -46,7 +46,7 @@ repos:
4646
name: Check executable files use .sh extension
4747
types: [shell, executable]
4848
- repo: https://github.com/astral-sh/ruff-pre-commit
49-
rev: v0.5.2
49+
rev: v0.5.4
5050
hooks:
5151
- id: ruff
5252
types_or: [python, pyi, jupyter]

src/squidpy/pl/_spatial_utils.py

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ class OutlineParams(NamedTuple):
8080

8181
outline: bool
8282
gap_size: float
83-
gap_color: str
83+
gap_color: NDArrayA | str
8484
bg_size: float
85-
bg_color: str
85+
bg_color: NDArrayA | str
8686

8787

8888
class ScalebarParams(NamedTuple):
@@ -287,7 +287,11 @@ def truthy(img: bool | NDArrayA | _SeqArray | None) -> bool:
287287
return img is True or len(img) # type: ignore
288288

289289
library_id = _get_library_id(
290-
adata=adata, shape=shape, spatial_key=spatial_key, library_id=library_id, library_key=library_key
290+
adata=adata,
291+
shape=shape,
292+
spatial_key=spatial_key,
293+
library_id=library_id,
294+
library_key=library_key,
291295
)
292296
if len(library_id) > 1 and library_key is None:
293297
raise ValueError(
@@ -342,7 +346,12 @@ def _set_coords_crops(
342346
if crop_coord is None:
343347
crops = [None] * len(spatial_params.library_id)
344348
else:
345-
crop_coord = _get_list(crop_coord, _type=tuple, ref_len=len(spatial_params.library_id), name="crop_coord")
349+
crop_coord = _get_list(
350+
crop_coord,
351+
_type=tuple,
352+
ref_len=len(spatial_params.library_id),
353+
name="crop_coord",
354+
)
346355
crops = [CropCoords(*cr) * sf for cr, sf in zip(crop_coord, spatial_params.scale_factor)] # type: ignore[misc]
347356

348357
coords = adata.obsm[spatial_key]
@@ -382,7 +391,10 @@ def subset_by_key(
382391
raise KeyError(f"Unable to find `{key!r}` in `adata.obs`.") from None
383392

384393
def subset_by_coords(
385-
adata: AnnData, coords: NDArrayA, img: NDArrayA | None, crop_coords: CropCoords | None
394+
adata: AnnData,
395+
coords: NDArrayA,
396+
img: NDArrayA | None,
397+
crop_coords: CropCoords | None,
386398
) -> tuple[AnnData, NDArrayA, NDArrayA | None]:
387399
if crop_coords is None:
388400
return adata, coords, img
@@ -463,7 +475,13 @@ def _set_color_source_vec(
463475
if groups is not None:
464476
color_source_vector = color_source_vector.remove_categories(categories.difference(groups))
465477

466-
color_map = _get_palette(adata, cluster_key=value_to_plot, categories=categories, palette=palette, alpha=alpha)
478+
color_map = _get_palette(
479+
adata,
480+
cluster_key=value_to_plot,
481+
categories=categories,
482+
palette=palette,
483+
alpha=alpha,
484+
)
467485
if color_map is None:
468486
raise ValueError("Unable to create color palette.")
469487
# do not rename categories, as colors need not be unique
@@ -546,7 +564,13 @@ def _plot_edges(
546564
if not len(g.edges):
547565
return None
548566
edge_collection = draw_networkx_edges(
549-
g, coords, width=edges_width, edge_color=edges_color, arrows=False, ax=ax, **kwargs
567+
g,
568+
coords,
569+
width=edges_width,
570+
edge_color=edges_color,
571+
arrows=False,
572+
ax=ax,
573+
**kwargs,
550574
)
551575
edge_collection.set_rasterized(sc_settings._vector_friendly)
552576
ax.add_collection(edge_collection)
@@ -635,7 +659,13 @@ def _decorate_axs(
635659
# Adding legends
636660
if color_source_vector is not None and isinstance(color_source_vector.dtype, CategoricalDtype):
637661
clusters = color_source_vector.categories
638-
palette = _get_palette(adata, cluster_key=value_to_plot, categories=clusters, palette=palette, alpha=alpha)
662+
palette = _get_palette(
663+
adata,
664+
cluster_key=value_to_plot,
665+
categories=clusters,
666+
palette=palette,
667+
alpha=alpha,
668+
)
639669
_add_categorical_legend(
640670
ax,
641671
color_source_vector,
@@ -792,7 +822,12 @@ def _prepare_params_plot(
792822
dpi = rcParams["figure.dpi"] if dpi is None else dpi
793823
if num_panels > 1 and ax is None:
794824
fig, grid = _panel_grid(
795-
num_panels=num_panels, hspace=hspace, wspace=wspace, ncols=ncols, dpi=dpi, figsize=figsize
825+
num_panels=num_panels,
826+
hspace=hspace,
827+
wspace=wspace,
828+
ncols=ncols,
829+
dpi=dpi,
830+
figsize=figsize,
796831
)
797832
axs: Sequence[Axes] | None = [plt.subplot(grid[c]) for c in range(num_panels)]
798833
elif num_panels > 1 and ax is not None:
@@ -925,7 +960,7 @@ def _plot_scatter(
925960
coords[:, 0],
926961
coords[:, 1],
927962
s=outline_params.bg_size,
928-
c=outline_params.bg_color,
963+
c=outline_params.bg_color, # type: ignore[arg-type]
929964
rasterized=sc_settings._vector_friendly,
930965
cmap=cmap_params.cmap,
931966
norm=norm,
@@ -936,7 +971,7 @@ def _plot_scatter(
936971
coords[:, 0],
937972
coords[:, 1],
938973
s=outline_params.gap_size,
939-
c=outline_params.gap_color,
974+
c=outline_params.gap_color, # type: ignore[arg-type]
940975
rasterized=sc_settings._vector_friendly,
941976
cmap=cmap_params.cmap,
942977
norm=norm,

0 commit comments

Comments
 (0)