|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
3 | 3 | from collections.abc import Iterable, Mapping, Sequence
|
| 4 | +from copy import copy |
| 5 | +from dataclasses import dataclass |
4 | 6 | from functools import partial
|
5 |
| -from typing import Any, NamedTuple, Optional, Union, Literal, Type |
6 | 7 | from types import MappingProxyType
|
7 |
| -from copy import copy |
| 8 | +from typing import Any, Literal, Optional, Type, Union |
| 9 | + |
8 | 10 | import matplotlib.pyplot as plt
|
9 | 11 | import numpy as np
|
10 | 12 | import pandas as pd
|
11 | 13 | import xarray as xr
|
12 | 14 | from anndata import AnnData
|
13 | 15 | from cycler import Cycler, cycler
|
14 |
| -from matplotlib import colors |
15 |
| -from matplotlib.colors import Colormap, ListedColormap, Normalize, to_rgba, TwoSlopeNorm |
| 16 | +from matplotlib import colors, patheffects |
| 17 | +from matplotlib import pyplot as plt |
| 18 | +from matplotlib import rcParams |
| 19 | +from matplotlib.axes import Axes |
16 | 20 | from matplotlib.cm import get_cmap
|
| 21 | +from matplotlib.collections import PatchCollection |
| 22 | +from matplotlib.colors import Colormap, ListedColormap, Normalize, TwoSlopeNorm, to_rgba |
| 23 | +from matplotlib.figure import Figure |
| 24 | +from matplotlib.gridspec import GridSpec |
| 25 | +from matplotlib_scalebar.scalebar import ScaleBar |
17 | 26 | from numpy.random import default_rng
|
18 | 27 | from pandas.api.types import CategoricalDtype, is_categorical_dtype
|
| 28 | +from scanpy.plotting._tools.scatterplots import _add_categorical_legend |
| 29 | +from scanpy.plotting.palettes import default_20, default_28, default_102 |
19 | 30 | from skimage.color import label2rgb
|
20 | 31 | from skimage.morphology import erosion, square
|
21 | 32 | from skimage.segmentation import find_boundaries
|
22 | 33 | from skimage.util import map_array
|
23 |
| -from spatialdata._types import ArrayLike |
24 | 34 | from spatialdata._logging import logger as logging
|
25 |
| -from matplotlib import rcParams |
26 |
| -from scanpy.plotting.palettes import default_20, default_28, default_102 |
27 |
| -from dataclasses import dataclass |
28 |
| -from matplotlib_scalebar.scalebar import ScaleBar |
29 |
| -from matplotlib.figure import Figure |
30 |
| -from matplotlib.gridspec import GridSpec |
31 |
| -from matplotlib import colors, patheffects, rcParams |
32 |
| -from matplotlib import pyplot as plt |
33 |
| -from matplotlib.axes import Axes |
34 |
| -from matplotlib.collections import Collection, PatchCollection |
35 |
| -from scanpy._settings import settings as sc_settings |
36 |
| -from scanpy.plotting._tools.scatterplots import _add_categorical_legend |
| 35 | +from spatialdata._types import ArrayLike |
37 | 36 |
|
38 | 37 | Palette_t = Optional[Union[str, ListedColormap]]
|
39 | 38 | _Normalize = Union[Normalize, Sequence[Normalize]]
|
@@ -89,7 +88,6 @@ def _prepare_params_plot(
|
89 | 88 | scalebar_dx: float | Sequence[float] | None = None,
|
90 | 89 | scalebar_units: str | Sequence[str] | None = None,
|
91 | 90 | ) -> tuple[FigParams, ScalebarParams]:
|
92 |
| - |
93 | 91 | # len(list(itertools.product(*iter_panels)))
|
94 | 92 |
|
95 | 93 | # handle axes and size
|
@@ -193,7 +191,6 @@ def _prepare_cmap_norm(
|
193 | 191 | vmax: float | None = None,
|
194 | 192 | vcenter: float | None = None,
|
195 | 193 | ) -> dataclass:
|
196 |
| - |
197 | 194 | cmap = copy(get_cmap(cmap))
|
198 | 195 | cmap.set_bad("lightgray" if na_color is None else na_color)
|
199 | 196 |
|
@@ -460,7 +457,6 @@ def _map_color_seg(
|
460 | 457 | seg_boundaries: bool = False,
|
461 | 458 | na_color: str | tuple[float, ...] = (0, 0, 0, 0),
|
462 | 459 | ) -> ArrayLike:
|
463 |
| - |
464 | 460 | cell_id = np.array(cell_id)
|
465 | 461 |
|
466 | 462 | if is_categorical_dtype(color_vector):
|
@@ -601,7 +597,6 @@ def _decorate_axs(
|
601 | 597 | scalebar_units: Sequence[str] | None = None,
|
602 | 598 | scalebar_kwargs: Mapping[str, Any] = MappingProxyType({}),
|
603 | 599 | ) -> Axes:
|
604 |
| - |
605 | 600 | ax.set_yticks([])
|
606 | 601 | ax.set_xticks([])
|
607 | 602 | # ax.set_xlabel(fig_params.ax_labels[0])
|
@@ -654,7 +649,7 @@ def _decorate_axs(
|
654 | 649 |
|
655 | 650 | def _get_list(
|
656 | 651 | var: Any,
|
657 |
| - _type: Type[Any] | tuple[Type[Any], ...], |
| 652 | + _type: type[Any] | tuple[type[Any], ...], |
658 | 653 | ref_len: int | None = None,
|
659 | 654 | name: str | None = None,
|
660 | 655 | ) -> list[Any]:
|
|
0 commit comments