|
24 | 24 | from collections.abc import Sequence
|
25 | 25 | from functools import lru_cache
|
26 | 26 | from types import ModuleType
|
27 |
| -from typing import Callable, Literal, Optional, Union, overload |
| 27 | +from typing import Callable, Literal, overload |
28 | 28 |
|
29 | 29 | import anndata as ad
|
30 | 30 | import numpy as np
|
@@ -98,7 +98,7 @@ def _structure_at_coordinates(
|
98 | 98 | *,
|
99 | 99 | multipliers: Sequence = itertools.repeat(1),
|
100 | 100 | 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], |
102 | 102 | ):
|
103 | 103 | """Update data with structure at given coordinates.
|
104 | 104 |
|
@@ -165,42 +165,42 @@ def _smallest_dtype(n: int) -> np.dtype:
|
165 | 165 | @overload
|
166 | 166 | def labeled_particles(
|
167 | 167 | shape: Sequence[int],
|
168 |
| - dtype: Optional[np.dtype] = None, |
| 168 | + dtype: np.dtype | None = None, |
169 | 169 | n: int = 144,
|
170 |
| - seed: Optional[int] = None, |
| 170 | + seed: int | None = None, |
171 | 171 | return_density: Literal[False] = False,
|
172 | 172 | ) -> np.ndarray: ...
|
173 | 173 |
|
174 | 174 |
|
175 | 175 | @overload
|
176 | 176 | def labeled_particles(
|
177 | 177 | shape: Sequence[int],
|
178 |
| - dtype: Optional[np.dtype] = None, |
| 178 | + dtype: np.dtype | None = None, |
179 | 179 | n: int = 144,
|
180 |
| - seed: Optional[int] = None, |
| 180 | + seed: int | None = None, |
181 | 181 | return_density: Literal[True] = True,
|
182 | 182 | ) -> tuple[np.ndarray, np.ndarray, np.ndarray]: ...
|
183 | 183 |
|
184 | 184 |
|
185 | 185 | @lru_cache
|
186 | 186 | def labeled_particles(
|
187 | 187 | shape: Sequence[int],
|
188 |
| - dtype: Optional[np.dtype] = None, |
| 188 | + dtype: np.dtype | None = None, |
189 | 189 | n: int = 144,
|
190 |
| - seed: Optional[int] = None, |
| 190 | + seed: int | None = None, |
191 | 191 | 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]: |
193 | 193 | """Generate labeled blobs of given shape and dtype.
|
194 | 194 |
|
195 | 195 | Parameters
|
196 | 196 | ----------
|
197 | 197 | shape : Sequence[int]
|
198 | 198 | Shape of the resulting array.
|
199 |
| - dtype : Optional[np.dtype] |
| 199 | + dtype : np.dtype | None |
200 | 200 | Dtype of the resulting array.
|
201 | 201 | n : int
|
202 | 202 | Number of blobs to generate.
|
203 |
| - seed : Optional[int] |
| 203 | + seed : int | None |
204 | 204 | Seed for the random number generator.
|
205 | 205 | return_density : bool
|
206 | 206 | Whether to return the density array and center coordinates.
|
|
0 commit comments