Skip to content

Commit 9ad7f5b

Browse files
authored
Merge branch 'main' into pre-commit-ci-update-config
2 parents 5dfe145 + 3f01688 commit 9ad7f5b

38 files changed

+104
-237
lines changed

benchmarks/utils.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from collections.abc import Sequence
2525
from functools import lru_cache
2626
from types import ModuleType
27-
from typing import Callable, Literal, Optional, Union, overload
27+
from typing import Callable, Literal, overload
2828

2929
import anndata as ad
3030
import numpy as np
@@ -98,7 +98,7 @@ def _structure_at_coordinates(
9898
*,
9999
multipliers: Sequence = itertools.repeat(1),
100100
dtype=None,
101-
reduce_fn: Callable[[np.ndarray, np.ndarray, Optional[np.ndarray]], np.ndarray],
101+
reduce_fn: Callable[[np.ndarray, np.ndarray, np.ndarray | None], np.ndarray],
102102
):
103103
"""Update data with structure at given coordinates.
104104
@@ -165,42 +165,42 @@ def _smallest_dtype(n: int) -> np.dtype:
165165
@overload
166166
def labeled_particles(
167167
shape: Sequence[int],
168-
dtype: Optional[np.dtype] = None,
168+
dtype: np.dtype | None = None,
169169
n: int = 144,
170-
seed: Optional[int] = None,
170+
seed: int | None = None,
171171
return_density: Literal[False] = False,
172172
) -> np.ndarray: ...
173173

174174

175175
@overload
176176
def labeled_particles(
177177
shape: Sequence[int],
178-
dtype: Optional[np.dtype] = None,
178+
dtype: np.dtype | None = None,
179179
n: int = 144,
180-
seed: Optional[int] = None,
180+
seed: int | None = None,
181181
return_density: Literal[True] = True,
182182
) -> tuple[np.ndarray, np.ndarray, np.ndarray]: ...
183183

184184

185185
@lru_cache
186186
def labeled_particles(
187187
shape: Sequence[int],
188-
dtype: Optional[np.dtype] = None,
188+
dtype: np.dtype | None = None,
189189
n: int = 144,
190-
seed: Optional[int] = None,
190+
seed: int | None = None,
191191
return_density: bool = False,
192-
) -> Union[np.ndarray, tuple[np.ndarray, np.ndarray, np.ndarray]]:
192+
) -> np.ndarray | tuple[np.ndarray, np.ndarray, np.ndarray]:
193193
"""Generate labeled blobs of given shape and dtype.
194194
195195
Parameters
196196
----------
197197
shape : Sequence[int]
198198
Shape of the resulting array.
199-
dtype : Optional[np.dtype]
199+
dtype : np.dtype | None
200200
Dtype of the resulting array.
201201
n : int
202202
Number of blobs to generate.
203-
seed : Optional[int]
203+
seed : int | None
204204
Seed for the random number generator.
205205
return_density : bool
206206
Whether to return the density array and center coordinates.

docs/design_doc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ In `spatialdata-io` we use a consistent naming scheme for the `region_key` and `
268268
### Summary
269269

270270
- Image `type: Image`
271-
- Regions `type: Union[Labels, Shapes]`
271+
- Regions `type: Labels | Shapes`
272272
- Labels `type: Labels`
273273
- Shapes `type: Shapes`
274274
- Points `type: Points`

src/spatialdata/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
import dask
42

53
dask.config.set({"dataframe.query-planning": False})

src/spatialdata/_core/_deepcopy.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
from copy import deepcopy as _deepcopy
42
from functools import singledispatch
53

src/spatialdata/_core/_elements.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""SpatialData elements."""
22

3-
from __future__ import annotations
4-
53
from collections import UserDict
64
from collections.abc import Iterable, KeysView, ValuesView
75
from typing import TypeVar

src/spatialdata/_core/_utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
from collections.abc import Iterable
42

53
from anndata import AnnData

src/spatialdata/_core/centroids.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
from collections import defaultdict
42
from functools import singledispatch
53

src/spatialdata/_core/concatenate.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
from collections import defaultdict
42
from collections.abc import Callable, Iterable
53
from copy import copy # Should probably go up at the top

src/spatialdata/_core/data_extent.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
from __future__ import annotations
2-
31
# Functions to compute the bounding box describing the extent of a SpatialElement or SpatialData object
42
from collections import defaultdict
53
from functools import singledispatch
6-
from typing import Union
74

85
import numpy as np
96
import pandas as pd
@@ -107,9 +104,7 @@ def get_extent(
107104
has_labels: bool = True,
108105
has_points: bool = True,
109106
has_shapes: bool = True,
110-
elements: Union[ # noqa: UP007 # https://github.com/scverse/spatialdata/pull/318#issuecomment-1755714287
111-
list[str], None
112-
] = None,
107+
elements: list[str] | None = None, # noqa: UP007 # https://github.com/scverse/spatialdata/pull/318#issuecomment-1755714287
113108
) -> BoundingBoxDescription:
114109
"""
115110
Get the extent (bounding box) of a SpatialData object or a SpatialElement.
@@ -178,9 +173,7 @@ def _(
178173
has_labels: bool = True,
179174
has_points: bool = True,
180175
has_shapes: bool = True,
181-
# python 3.9 tests fail if we don't use Union here, see
182-
# https://github.com/scverse/spatialdata/pull/318#issuecomment-1755714287
183-
elements: Union[list[str], None] = None, # noqa: UP007
176+
elements: list[str] | None = None,
184177
) -> BoundingBoxDescription:
185178
"""
186179
Get the extent (bounding box) of a SpatialData object.

src/spatialdata/_core/operations/aggregate.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
import warnings
42
from typing import Any
53

@@ -21,14 +19,7 @@
2119
from spatialdata._core.query.relational_query import get_values
2220
from spatialdata._core.spatialdata import SpatialData
2321
from spatialdata._types import ArrayLike
24-
from spatialdata.models import (
25-
Image2DModel,
26-
Labels2DModel,
27-
PointsModel,
28-
ShapesModel,
29-
TableModel,
30-
get_model,
31-
)
22+
from spatialdata.models import Image2DModel, Labels2DModel, PointsModel, ShapesModel, TableModel, get_model
3223
from spatialdata.transformations import BaseTransformation, Identity, get_transformation
3324

3425
__all__ = ["aggregate"]

0 commit comments

Comments
 (0)