|
4 | 4 | from collections import OrderedDict
|
5 | 5 | from collections.abc import Sequence
|
6 | 6 | from pathlib import Path
|
7 |
| -from typing import Any, Optional, Union |
| 7 | +from typing import Any |
8 | 8 |
|
9 | 9 | import matplotlib.pyplot as plt
|
10 | 10 | import scanpy as sc
|
@@ -82,11 +82,11 @@ def __init__(self, sdata: sd.SpatialData) -> None:
|
82 | 82 |
|
83 | 83 | def _copy(
|
84 | 84 | self,
|
85 |
| - images: Union[None, dict[str, Union[SpatialImage, MultiscaleSpatialImage]]] = None, |
86 |
| - labels: Union[None, dict[str, Union[SpatialImage, MultiscaleSpatialImage]]] = None, |
87 |
| - points: Union[None, dict[str, DaskDataFrame]] = None, |
88 |
| - shapes: Union[None, dict[str, GeoDataFrame]] = None, |
89 |
| - table: Union[None, AnnData] = None, |
| 85 | + images: None | dict[str, SpatialImage | MultiscaleSpatialImage] = None, |
| 86 | + labels: None | dict[str, SpatialImage | MultiscaleSpatialImage] = None, |
| 87 | + points: None | dict[str, DaskDataFrame] = None, |
| 88 | + shapes: None | dict[str, GeoDataFrame] = None, |
| 89 | + table: None | AnnData = None, |
90 | 90 | ) -> sd.SpatialData:
|
91 | 91 | """Copy the current `SpatialData` object, optionally modifying some of its attributes.
|
92 | 92 |
|
@@ -150,7 +150,7 @@ def render_shapes(
|
150 | 150 | layer: str | None = None,
|
151 | 151 | palette: Palette_t = None,
|
152 | 152 | cmap: Colormap | str | None = None,
|
153 |
| - norm: Optional[Normalize] = None, |
| 153 | + norm: None | Normalize = None, |
154 | 154 | na_color: str | tuple[float, ...] | None = "lightgrey",
|
155 | 155 | outline_alpha: float = 1.0,
|
156 | 156 | fill_alpha: float = 1.0,
|
@@ -232,7 +232,7 @@ def render_points(
|
232 | 232 | size: float = 1.0,
|
233 | 233 | palette: Palette_t = None,
|
234 | 234 | cmap: Colormap | str | None = None,
|
235 |
| - norm: Optional[Normalize] = None, |
| 235 | + norm: None | Normalize = None, |
236 | 236 | na_color: str | tuple[float, ...] | None = (0.0, 0.0, 0.0, 0.0),
|
237 | 237 | alpha: float = 1.0,
|
238 | 238 | **kwargs: Any,
|
@@ -296,7 +296,7 @@ def render_images(
|
296 | 296 | elements: str | list[str] | None = None,
|
297 | 297 | channel: list[str] | list[int] | int | str | None = None,
|
298 | 298 | cmap: Colormap | str | None = None,
|
299 |
| - norm: Optional[Normalize] = None, |
| 299 | + norm: None | Normalize = None, |
300 | 300 | na_color: str | tuple[float, ...] | None = (0.0, 0.0, 0.0, 0.0),
|
301 | 301 | palette: Palette_t = None,
|
302 | 302 | alpha: float = 1.0,
|
@@ -358,7 +358,7 @@ def render_labels(
|
358 | 358 | layer: str | None = None,
|
359 | 359 | palette: Palette_t = None,
|
360 | 360 | cmap: Colormap | str | None = None,
|
361 |
| - norm: Optional[Normalize] = None, |
| 361 | + norm: None | Normalize = None, |
362 | 362 | na_color: str | tuple[float, ...] | None = (0.0, 0.0, 0.0, 0.0),
|
363 | 363 | outline_alpha: float = 1.0,
|
364 | 364 | fill_alpha: float = 0.3,
|
@@ -452,11 +452,11 @@ def show(
|
452 | 452 | figsize: tuple[float, float] | None = None,
|
453 | 453 | dpi: int | None = None,
|
454 | 454 | fig: Figure | None = None,
|
455 |
| - title: Optional[Union[str, Sequence[str]]] = None, |
| 455 | + title: None | str | Sequence[str] = None, |
456 | 456 | share_extent: bool = True,
|
457 | 457 | ax: Axes | Sequence[Axes] | None = None,
|
458 | 458 | return_ax: bool = False,
|
459 |
| - save: Optional[Union[str, Path]] = None, |
| 459 | + save: None | str | Path = None, |
460 | 460 | ) -> sd.SpatialData:
|
461 | 461 | """
|
462 | 462 | Plot the images in the SpatialData object.
|
@@ -517,7 +517,7 @@ def show(
|
517 | 517 | if isinstance(title, str):
|
518 | 518 | title = [title]
|
519 | 519 |
|
520 |
| - if not all([isinstance(t, str) for t in title]): |
| 520 | + if not all(isinstance(t, str) for t in title): |
521 | 521 | raise TypeError("All titles must be strings.")
|
522 | 522 |
|
523 | 523 | # Simplicstic solution: If the images are multiscale, just use the first
|
|
0 commit comments