Skip to content

Commit 6717cf0

Browse files
[pre-commit.ci] pre-commit autoupdate (#926)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.7.2 → v0.7.3](astral-sh/ruff-pre-commit@v0.7.2...v0.7.3) * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.1 → v0.9.1](astral-sh/ruff-pre-commit@v0.8.1...v0.9.1) - [github.com/pre-commit/mirrors-mypy: v1.13.0 → v1.14.1](pre-commit/mirrors-mypy@v1.13.0...v1.14.1) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixed mypy * copied upper limited for dask from sdata --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tim Treis <[email protected]> Co-authored-by: Tim Treis <[email protected]>
1 parent 0e4385d commit 6717cf0

File tree

10 files changed

+30
-29
lines changed

10 files changed

+30
-29
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ default_stages:
55
minimum_pre_commit_version: 2.9.3
66
repos:
77
- repo: https://github.com/astral-sh/ruff-pre-commit
8-
rev: v0.8.1
8+
rev: v0.9.1
99
hooks:
1010
- id: ruff
1111
types_or: [python, pyi, jupyter]
@@ -17,7 +17,7 @@ repos:
1717
hooks:
1818
- id: blacken-docs
1919
- repo: https://github.com/pre-commit/mirrors-mypy
20-
rev: v1.13.0
20+
rev: v1.14.1
2121
hooks:
2222
- id: mypy
2323
additional_dependencies: [numpy, pandas, types-requests]

docs/_ext/typed_returns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def _process_return(lines: Iterable[str]) -> Iterator[str]:
1212
m = re.fullmatch(r"(?P<param>\w+)\s+:\s+(?P<type>[\w.]+)", line)
1313
if m:
1414
# Once this is in scanpydoc, we can use the fancy hover stuff
15-
yield f'**{m["param"]}** : :class:`~{m["type"]}`'
15+
yield f"**{m['param']}** : :class:`~{m['type']}`"
1616
else:
1717
yield line
1818

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ dependencies = [
5151
"anndata>=0.9",
5252
"cycler>=0.11.0",
5353
"dask-image>=0.5.0",
54-
"dask[array]>=2021.02.0",
54+
"dask[array]>=2021.02.0,<=2024.11.2",
5555
"docrep>=0.3.1",
5656
"fsspec>=2021.11.0",
5757
"leidenalg>=0.8.2",

src/squidpy/datasets/_dataset.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@
7474
)
7575
_slideseqv2 = AMetadata(
7676
name="slideseqv2",
77-
doc_header="Pre-processed SlideseqV2 dataset from `Stickles et al "
78-
"<https://doi.org/10.1038/s41587-020-0739-1>`__.",
77+
doc_header="Pre-processed SlideseqV2 dataset from `Stickles et al <https://doi.org/10.1038/s41587-020-0739-1>`__.",
7978
shape=(41786, 4000),
8079
url="https://ndownloader.figshare.com/files/28242783",
8180
)

src/squidpy/gr/_build.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from collections.abc import Iterable # noqa: F401
77
from functools import partial
88
from itertools import chain
9-
from typing import Any
9+
from typing import Any, cast
1010

1111
import geopandas as gpd
1212
import numpy as np
@@ -145,16 +145,16 @@ def spatial_neighbors(
145145
- :attr:`anndata.AnnData.uns` ``['{{key_added}}']`` - :class:`dict` containing parameters.
146146
"""
147147
if isinstance(adata, SpatialData):
148-
assert (
149-
elements_to_coordinate_systems is not None
150-
), "Since `adata` is a :class:`spatialdata.SpatialData`, `elements_to_coordinate_systems` must not be `None`."
151-
assert (
152-
table_key is not None
153-
), "Since `adata` is a :class:`spatialdata.SpatialData`, `table_key` must not be `None`."
148+
assert elements_to_coordinate_systems is not None, (
149+
"Since `adata` is a :class:`spatialdata.SpatialData`, `elements_to_coordinate_systems` must not be `None`."
150+
)
151+
assert table_key is not None, (
152+
"Since `adata` is a :class:`spatialdata.SpatialData`, `table_key` must not be `None`."
153+
)
154154
elements, table = match_element_to_table(adata, list(elements_to_coordinate_systems), table_key)
155-
assert table.obs_names.equals(
156-
adata.tables[table_key].obs_names
157-
), "The spatialdata table must annotate all elements keys. Some elements are missing, please check the `elements_to_coordinate_systems` dictionary."
155+
assert table.obs_names.equals(adata.tables[table_key].obs_names), (
156+
"The spatialdata table must annotate all elements keys. Some elements are missing, please check the `elements_to_coordinate_systems` dictionary."
157+
)
158158
regions, region_key, instance_key = get_table_keys(adata.tables[table_key])
159159
regions = [regions] if isinstance(regions, str) else regions
160160
ordered_regions_in_table = adata.tables[table_key].obs[region_key].unique()
@@ -237,7 +237,7 @@ def spatial_neighbors(
237237
for lib in libs:
238238
ixs.extend(np.where(adata.obs[library_key] == lib)[0])
239239
mats.append(_build_fun(adata[adata.obs[library_key] == lib]))
240-
ixs = np.argsort(ixs).tolist() # invert
240+
ixs = cast(list[int], np.argsort(ixs).tolist())
241241
Adj = block_diag([m[0] for m in mats], format="csr")[ixs, :][:, ixs]
242242
Dst = block_diag([m[1] for m in mats], format="csr")[ixs, :][:, ixs]
243243
else:

src/squidpy/gr/_ligrec.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,7 @@ def test(
441441

442442
if corr_method is not None:
443443
logg.info(
444-
f"Performing FDR correction across the `{corr_axis.v}` "
445-
f"using method `{corr_method}` at level `{alpha}`"
444+
f"Performing FDR correction across the `{corr_axis.v}` using method `{corr_method}` at level `{alpha}`"
446445
)
447446
res["pvalues"] = _fdr_correct(res["pvalues"], corr_method, corr_axis, alpha=alpha)
448447

src/squidpy/im/_container.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,7 @@ def generate_spot_crops(
802802
obs_library_ids = list(adata.obs[library_id])
803803
except KeyError:
804804
logg.debug(
805-
f"Unable to find library ids in `adata.obs[{library_id!r}]`. "
806-
f"Trying in `adata.uns[{spatial_key!r}]`"
805+
f"Unable to find library ids in `adata.obs[{library_id!r}]`. Trying in `adata.uns[{spatial_key!r}]`"
807806
)
808807
library_id = Key.uns.library_id(adata, spatial_key=spatial_key, library_id=library_id)
809808
if not isinstance(library_id, str):
@@ -1622,7 +1621,7 @@ def _repr_html_(self) -> str:
16221621
)
16231622
s += "</p>"
16241623
if i == 9 and i < len(self) - 1: # show only first 10 layers
1625-
s += f"<p style={style!r}>and {len(self) - i - 1} more...</p>"
1624+
s += f"<p style={style!r}>and {len(self) - i - 1} more...</p>"
16261625
break
16271626

16281627
return s

src/squidpy/pl/_ligrec.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ def __init__(self, minn: float, delta: float, alpha: float | None, *args: Any, *
4141
def _plot_size_legend(self, size_legend_ax: Axes) -> None:
4242
y = self.BASE ** -((self.dot_max * self._delta) + self._minn)
4343
x = self.BASE ** -((self.dot_min * self._delta) + self._minn)
44-
size_range = -(np.logspace(x, y, self.DEFAULT_NUM_LEGEND_DOTS + 1, base=10).astype(np.float64))
45-
size_range = (size_range - np.min(size_range)) / (np.max(size_range) - np.min(size_range))
44+
size_range = -np.logspace(x, y, self.DEFAULT_NUM_LEGEND_DOTS + 1, base=10, dtype=np.float64)
45+
size_range = ((size_range - np.min(size_range)) / (np.max(size_range) - np.min(size_range))).astype(np.float64)
46+
4647
# no point in showing dot of size 0
4748
size_range = size_range[1:]
4849

src/squidpy/pl/_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ def _warn_if_exists_obs(adata: AnnData, obs_key: str) -> None:
178178
@njit(cache=True, fastmath=True)
179179
def _point_inside_triangles(triangles: NDArrayA) -> np.bool_:
180180
# modified from napari
181-
AB = triangles[:, 1, :] - triangles[:, 0, :]
182-
AC = triangles[:, 2, :] - triangles[:, 0, :]
183-
BC = triangles[:, 2, :] - triangles[:, 1, :]
181+
AB: NDArrayA = triangles[:, 1, :] - triangles[:, 0, :]
182+
AC: NDArrayA = triangles[:, 2, :] - triangles[:, 0, :]
183+
BC: NDArrayA = triangles[:, 2, :] - triangles[:, 1, :]
184184

185185
s_AB = -AB[:, 0] * triangles[:, 0, 1] + AB[:, 1] * triangles[:, 0, 0] >= 0
186186
s_AC = -AC[:, 0] * triangles[:, 0, 1] + AC[:, 1] * triangles[:, 0, 0] >= 0

src/squidpy/tl/_var_by_distance.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from collections.abc import Iterator
44
from functools import reduce
55
from itertools import product
6-
from typing import Any, Union
6+
from typing import Any, Union, cast
77

88
import numpy as np
99
import pandas as pd
@@ -67,7 +67,10 @@ def var_by_distance(
6767
elif isinstance(groups, list):
6868
anchor = groups
6969
elif isinstance(groups, np.ndarray):
70-
anchor = groups.tolist()
70+
# can't be a 2D array
71+
if groups.ndim != 1:
72+
raise ValueError(f"Expected a 1D array for 'groups', but got shape {groups.shape}.")
73+
anchor = cast(list[str], groups.astype(str).tolist())
7174
else:
7275
raise TypeError(f"Invalid type for groups: {type(groups)}.")
7376

0 commit comments

Comments
 (0)