Skip to content

Commit

Permalink
fix precommit (#881)
Browse files Browse the repository at this point in the history
* update

* update

* update

* update

* remove 3.9 from test

* remove py39 from lint

* add release note
  • Loading branch information
giovp authored Aug 30, 2024
1 parent 89ea7d2 commit 1405d49
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python 3.9
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11

- uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: [3.9, "3.10", "3.11"]
python: ["3.10", "3.11", "3.12"]
os: [ubuntu-latest]
include:
- python: "3.12"
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ default_stages:
minimum_pre_commit_version: 2.9.3
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.2
rev: v0.6.3
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
Expand All @@ -19,7 +19,7 @@ repos:
hooks:
- id: blacken-docs
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.1
rev: v1.11.2
hooks:
- id: mypy
additional_dependencies: [numpy, pandas, types-requests]
Expand Down
3 changes: 2 additions & 1 deletion docs/release/notes-1.6.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ Maintenance

- The Squidpy `interactive` module has been removed. Please use the ``napari-spatialdata`` plugin instead. You can find it `here <https://spatialdata.scverse.org/projects/napari/en/latest/index.html>`__ `@giovp <https://github.com/giovp>`__
`#877 <https://github.com/scverse/squidpy/pull/877>`__

- Drop support for Python 3.9 `@giovp <https://github.com/giovp>`__
`#881 <https://github.com/scverse/squidpy/pull/881>`__
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ classifiers = [
"Operating System :: MacOS :: MacOS X",
"Typing :: Typed",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Environment :: Console",
"Framework :: Jupyter",
"Intended Audience :: Science/Research",
Expand Down
2 changes: 1 addition & 1 deletion src/squidpy/gr/_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def spatial_neighbors(
for lib in libs:
ixs.extend(np.where(adata.obs[library_key] == lib)[0])
mats.append(_build_fun(adata[adata.obs[library_key] == lib]))
ixs = np.argsort(ixs) # type: ignore[assignment] # invert
ixs = np.argsort(ixs) # invert
Adj = block_diag([m[0] for m in mats], format="csr")[ixs, :][:, ixs]
Dst = block_diag([m[1] for m in mats], format="csr")[ixs, :][:, ixs]
else:
Expand Down
10 changes: 5 additions & 5 deletions src/squidpy/gr/_ppatterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def extract_obsm(adata: AnnData, ixs: int | Sequence[int] | None) -> tuple[NDArr
if layer not in adata.obsm:
raise KeyError(f"Key `{layer!r}` not found in `adata.obsm`.")
if ixs is None:
ixs = np.arange(adata.obsm[layer].shape[1]) # type:ignore[assignment]
ixs = np.arange(adata.obsm[layer].shape[1])
ixs = list(np.ravel([ixs]))
return adata.obsm[layer][:, ixs].T, ixs

Expand Down Expand Up @@ -429,10 +429,10 @@ def co_occurrence(
n_splits = max(min(n_splits, n_obs), 1)

# split array and labels
spatial_splits = tuple(s for s in np.array_split(spatial, n_splits, axis=0) if len(s)) # type:ignore[arg-type]
labs_splits = tuple(s for s in np.array_split(labs, n_splits, axis=0) if len(s)) # type:ignore[arg-type]
spatial_splits = tuple(s for s in np.array_split(spatial, n_splits, axis=0) if len(s))
labs_splits = tuple(s for s in np.array_split(labs, n_splits, axis=0) if len(s))
# create idx array including unique combinations and self-comparison
x, y = np.triu_indices_from(np.empty((n_splits, n_splits))) # type:ignore[arg-type]
x, y = np.triu_indices_from(np.empty((n_splits, n_splits)))
idx_splits = list(zip(x, y))

n_jobs = _get_n_cores(n_jobs)
Expand Down Expand Up @@ -578,7 +578,7 @@ def _g_moments(w: spmatrix | NDArrayA) -> tuple[float, float, float]:

# s1
t = w.transpose() + w
t2 = t.multiply(t) # type:ignore[union-attr]
t2 = t.multiply(t)
s1 = t2.sum() / 2.0

# s2
Expand Down
4 changes: 2 additions & 2 deletions src/squidpy/gr/_sepal.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ def _score_helper(

score, sparse = [], issparse(vals)
for i in ixs:
conc = vals[:, i].toarray().flatten() if sparse else vals[:, i].copy() # type:ignore[union-attr]
conc = vals[:, i].toarray().flatten() if sparse else vals[:, i].copy() # type:ignore[union-attr]
conc = vals[:, i].toarray().flatten() if sparse else vals[:, i].copy()
conc = vals[:, i].toarray().flatten() if sparse else vals[:, i].copy()
time_iter = _diffusion(conc, fun, n_iter, sat, sat_idx, unsat, unsat_idx, dt=dt, thresh=thresh)
score.append(dt * time_iter)

Expand Down
4 changes: 2 additions & 2 deletions src/squidpy/im/_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,12 +983,12 @@ def show(
arr = arr.sel(z=library_ids)

if channel is not None:
channel = np.asarray([channel]).ravel() # type: ignore[assignment]
channel = np.asarray([channel]).ravel()
if not len(channel): # type: ignore[arg-type]
raise ValueError("No channels have been selected.")
arr = arr[{arr.dims[-1]: channel}]
else:
channel = np.arange(arr.shape[-1]) # type: ignore[assignment]
channel = np.arange(arr.shape[-1])
if TYPE_CHECKING:
assert isinstance(channel, Sequence)

Expand Down
6 changes: 3 additions & 3 deletions src/squidpy/im/_feature_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,14 @@ def convert_to_full_image_coordinates(x: NDArrayA, y: NDArrayA) -> NDArrayA:
y_slc, x_slc = coord.to_image_coordinates(padding).slice

# relative coordinates
y = (y - np.min(y)) / (np.max(y) - np.min(y))
x = (x - np.min(x)) / (np.max(x) - np.min(x))
y = (y - np.min(y)) / (np.max(y) - np.min(y)) # type:ignore[operator]
x = (x - np.min(x)) / (np.max(x) - np.min(x)) # type:ignore[operator]

# coordinates in the uncropped image
y = coord.slice[0].start + (y_slc.stop - y_slc.start) * y
x = coord.slice[1].start + (x_slc.stop - x_slc.start) * x

return np.c_[x, y] # type: ignore[no-any-return]
return np.c_[x, y]

label_layer = self._get_layer(label_layer)
library_id = self._get_library_id(library_id)
Expand Down
2 changes: 1 addition & 1 deletion src/squidpy/im/_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def _postcondition(img: NDArrayA | da.Array) -> NDArrayA | da.Array:
def _(self, img: NDArrayA, **kwargs: Any) -> NDArrayA:
chunks = kwargs.pop("chunks", None)
if chunks is not None:
return self.segment(da.asarray(img).rechunk(chunks), **kwargs) # type: ignore[no-any-return]
return self.segment(da.asarray(img).rechunk(chunks), **kwargs)

img = SegmentationModel._precondition(img)
img = self._segment(img, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion src/squidpy/pl/_ligrec.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _plot_size_legend(self, size_legend_ax: Axes) -> None:
y = self.BASE ** -((self.dot_max * self._delta) + self._minn)
x = self.BASE ** -((self.dot_min * self._delta) + self._minn)
size_range = -(np.logspace(x, y, self.DEFAULT_NUM_LEGEND_DOTS + 1, base=10).astype(np.float64))
size_range = (size_range - np.min(size_range)) / (np.max(size_range) - np.min(size_range))
size_range = (size_range - np.min(size_range)) / (np.max(size_range) - np.min(size_range)) # type:ignore[operator]
# no point in showing dot of size 0
size_range = size_range[1:]

Expand Down
8 changes: 4 additions & 4 deletions src/squidpy/pl/_spatial_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,8 @@ def _map_color_seg(
if isinstance(color_vector.dtype, CategoricalDtype):
if isinstance(na_color, tuple) and len(na_color) == 4 and np.any(color_source_vector.isna()):
cell_id[color_source_vector.isna()] = 0
val_im: NDArrayA = map_array(seg, cell_id, color_vector.codes + 1) # type: ignore[union-attr]
cols = colors.to_rgba_array(color_vector.categories) # type: ignore[union-attr]
val_im: NDArrayA = map_array(seg, cell_id, color_vector.codes + 1)
cols = colors.to_rgba_array(color_vector.categories)
else:
val_im = map_array(seg, cell_id, cell_id) # replace with same seg id to remove missing segs
try:
Expand Down Expand Up @@ -960,7 +960,7 @@ def _plot_scatter(
coords[:, 0],
coords[:, 1],
s=outline_params.bg_size,
c=outline_params.bg_color, # type: ignore[arg-type]
c=outline_params.bg_color,
rasterized=sc_settings._vector_friendly,
cmap=cmap_params.cmap,
norm=norm,
Expand All @@ -971,7 +971,7 @@ def _plot_scatter(
coords[:, 0],
coords[:, 1],
s=outline_params.gap_size,
c=outline_params.gap_color, # type: ignore[arg-type]
c=outline_params.gap_color,
rasterized=sc_settings._vector_friendly,
cmap=cmap_params.cmap,
norm=norm,
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ sort = Miss

[gh-actions]
python =
3.8: py38
3.9: py39
3.10: py310
3.11: py311
3.12: py312

[gh-actions:env]
PLATFORM =
Expand All @@ -55,7 +55,7 @@ isolated_build = True
envlist =
covclean
lint
py{3.9,3.10}-{linux,macos}
py{3.10,3.11}-{linux,macos}
coverage
readme
check-docs
Expand Down Expand Up @@ -93,7 +93,7 @@ deps =
coverage
diff_cover
skip_install = true
depends = py{38,39,310}-{linux,macos}
depends = py{310,311,312}-{linux,macos}
parallel_show_output = True
commands =
coverage report --omit="tox/*"
Expand Down

0 comments on commit 1405d49

Please sign in to comment.