Skip to content

Commit 192ef2f

Browse files
timtreisclaude
andcommitted
Revert unrelated config and source changes to match main
Restores pyproject.toml, hatch.toml, test.yaml, pre-commit config, and gr/ source files that were inadvertently modified by earlier merge commits on this branch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9722ea1 commit 192ef2f

9 files changed

Lines changed: 185 additions & 82 deletions

File tree

.github/workflows/test.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,10 @@ jobs:
100100
env: { name: hatch-test.py3.11-stable }
101101
- os: macos-latest
102102
env: { name: hatch-test.py3.12-stable }
103-
- os: macos-latest
104-
env: { name: hatch-test.py3.13-pre } # pre-release only needs one OS
105103
- os: ubuntu-latest
106104
env: { name: hatch-test.py3.13-stable } # skipping because we run this as a coverage job
107105
name: ${{ matrix.env.label }} (${{ matrix.os }})
108106
runs-on: ${{ matrix.os }}
109-
continue-on-error: ${{ contains(matrix.env.name, 'pre') }}
110107
steps:
111108
- uses: actions/checkout@v5
112109
with:

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ default_stages:
77
minimum_pre_commit_version: 2.16.0
88
repos:
99
- repo: https://github.com/biomejs/pre-commit
10-
rev: v2.3.15
10+
rev: v2.3.10
1111
hooks:
1212
- id: biome-format
1313
exclude: ^\.cruft\.json$ # inconsistent indentation with cruft - file never to be modified manually.
1414
- repo: https://github.com/tox-dev/pyproject-fmt
15-
rev: v2.16.0
15+
rev: v2.11.1
1616
hooks:
1717
- id: pyproject-fmt
1818
- repo: https://github.com/astral-sh/ruff-pre-commit
19-
rev: v0.15.1
19+
rev: v0.14.11
2020
hooks:
2121
- id: ruff-check
2222
types_or: [python, pyi, jupyter]

hatch.toml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,17 @@ download = "python ./.scripts/ci/download_data.py {args}"
3939
deps = ["stable"]
4040
python = ["3.11", "3.12", "3.13"]
4141

42-
[[envs.hatch-test.matrix]]
43-
deps = ["pre"]
44-
python = ["3.13"]
42+
# Test the newest supported Python version also with pre-release deps
43+
# [[envs.hatch-test.matrix]]
44+
# deps = [ "pre" ]
45+
# python = [ "3.13" ]
4546

46-
[envs.hatch-test.overrides]
47-
matrix.deps.env-vars = [
48-
{ key = "UV_PRERELEASE", value = "allow", if = ["pre"] },
49-
]
47+
# [envs.hatch-test.overrides]
48+
# If the matrix variable `deps` is set to "pre",
49+
# set the environment variable `UV_PRERELEASE` to "allow".
50+
# matrix.deps.env-vars = [
51+
# { key = "UV_PRERELEASE", value = "allow", if = [ "pre" ] },
52+
# ]
5053

5154
[envs.notebooks]
5255
extra-dependencies = [

pyproject.toml

Lines changed: 73 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ keywords = [
1515
]
1616
license = "BSD-3-Clause"
1717
maintainers = [
18-
{ name = "Selman Ozleyen", email = "selman.ozleyen@helmholtz-munich.de" },
1918
{ name = "Tim Treis", email = "tim.treis@scverse.org" },
19+
{ name = "Selman Ozleyen", email = "selman.ozleyen@helmholtz-munich.de" },
2020
]
2121
authors = [
2222
{ name = "scverse" },
@@ -67,7 +67,7 @@ dependencies = [
6767
# due to https://github.com/scikit-image/scikit-image/issues/6850 breaks rescale ufunc
6868
"scikit-learn>=0.24",
6969
"spatialdata>=0.7.1",
70-
"spatialdata-plot>=0.2.13",
70+
"spatialdata-plot",
7171
"statsmodels>=0.12",
7272
# https://github.com/scverse/squidpy/issues/526
7373
"tifffile!=2022.4.22",
@@ -76,6 +76,7 @@ dependencies = [
7676
"xarray>=2024.10",
7777
"zarr>=3",
7878
]
79+
7980
optional-dependencies.dev = [
8081
"hatch>=1.9",
8182
"ipykernel",
@@ -127,11 +128,17 @@ include-package-data = true
127128

128129
[tool.setuptools_scm]
129130

130-
[tool.hatch]
131-
build.hooks.vcs.version-file = "_version.py"
132-
build.targets.wheel.packages = [ "src/squidpy" ]
133-
metadata.allow-direct-references = true
134-
version.source = "vcs"
131+
[tool.hatch.version]
132+
source = "vcs"
133+
134+
[tool.hatch.build.hooks.vcs]
135+
version-file = "_version.py"
136+
137+
[tool.hatch.metadata]
138+
allow-direct-references = true
139+
140+
[tool.hatch.build.targets.wheel]
141+
packages = [ "src/squidpy" ]
135142

136143
[tool.ruff]
137144
line-length = 120
@@ -144,6 +151,7 @@ exclude = [
144151
"docs/_build",
145152
"setup.py",
146153
]
154+
147155
format.docstring-code-format = true
148156
lint.select = [
149157
"B", # flake8-bugbear
@@ -153,8 +161,8 @@ lint.select = [
153161
"F", # pyflakes
154162
"I", # isort
155163
# below are not autofixed
156-
"UP", # pyupgrade
157-
"W", # pycodestyle
164+
"UP", # pyupgrade
165+
"W", # pycodestyle
158166
]
159167
# "squidpy/*.py"= ["RST303"]
160168
lint.ignore = [
@@ -226,46 +234,84 @@ lint.unfixable = [
226234
lint.flake8-tidy-imports.ban-relative-imports = "all"
227235
lint.isort.required-imports = [ "from __future__ import annotations" ]
228236

229-
[tool.pytest]
230-
ini_options.filterwarnings = [
237+
[tool.pytest.ini_options]
238+
filterwarnings = [
231239
"error::numba.NumbaPerformanceWarning",
232240
"ignore::UserWarning",
233241
"ignore::anndata.OldFormatWarning",
234242
"ignore:.*pkg_resources:DeprecationWarning",
235243
]
236-
ini_options.python_files = "test_*.py"
237-
ini_options.testpaths = [ "tests/" ]
238-
ini_options.xfail_strict = true
239-
ini_options.addopts = [
244+
python_files = "test_*.py"
245+
testpaths = [ "tests/" ]
246+
xfail_strict = true
247+
addopts = [
240248
"--ignore=tests/plotting/test_interactive.py",
241249
"--ignore=docs",
242250
]
243251

244-
[tool.coverage]
245-
run.branch = true
246-
run.omit = [
252+
[tool.coverage.run]
253+
branch = true
254+
parallel = true
255+
source = [ "squidpy" ]
256+
omit = [
247257
"*/__init__.py",
248258
"*/_version.py",
249259
"squidpy/pl/_interactive/*",
250260
"tox/*",
251261
]
252-
run.parallel = true
253-
run.source = [ "squidpy" ]
254-
paths.source = [
262+
263+
[tool.coverage.paths]
264+
source = [
255265
"squidpy",
256266
"*/site-packages/squidpy",
257267
]
258-
report.exclude_lines = [
268+
269+
[tool.coverage.report]
270+
exclude_lines = [
259271
"\\#.*pragma:\\s*no.?cover",
272+
"^if __name__ == .__main__.:$",
260273
"^\\s*raise AssertionError\\b",
261274
"^\\s*raise NotImplementedError\\b",
262275
"^\\s*return NotImplemented\\b",
263-
"^if __name__ == .__main__.:$",
264276
]
265-
report.precision = 2
266-
report.show_missing = true
267-
report.skip_empty = true
268-
report.sort = "Miss"
277+
show_missing = true
278+
precision = 2
279+
skip_empty = true
280+
sort = "Miss"
281+
282+
[tool.pixi.workspace]
283+
channels = [ "conda-forge" ]
284+
platforms = [ "osx-arm64", "linux-64" ]
285+
286+
[tool.pixi.dependencies]
287+
python = ">=3.11"
288+
289+
[tool.pixi.pypi-dependencies]
290+
squidpy = { path = ".", editable = true }
291+
292+
[tool.pixi.feature.py311.dependencies]
293+
python = "3.11.*"
294+
295+
[tool.pixi.feature.py313.dependencies]
296+
python = "3.13.*"
297+
298+
[tool.pixi.environments]
299+
dev-py311 = { features = [ "dev", "test", "py311" ], solve-group = "py311" }
300+
docs-py311 = { features = [ "docs", "py311" ], solve-group = "py311" }
301+
302+
default = { features = [ "py313" ], solve-group = "py313" }
303+
dev-py313 = { features = [ "dev", "test", "py313" ], solve-group = "py313" }
304+
docs-py313 = { features = [ "docs", "py313" ], solve-group = "py313" }
305+
test-py313 = { features = [ "test", "py313" ], solve-group = "py313" }
306+
307+
[tool.pixi.tasks]
308+
lab = "jupyter lab"
309+
kernel-install = "python -m ipykernel install --user --name pixi-dev --display-name \"squidpy (dev)\""
310+
test = "pytest -v --color=yes --tb=short --durations=10"
311+
lint = "ruff check ."
312+
format = "ruff format ."
313+
pre-commit-install = "pre-commit install"
314+
pre-commit = "pre-commit run"
269315

270316
[tool.cruft]
271317
skip = [
@@ -278,24 +324,3 @@ skip = [
278324
"docs/references.md",
279325
"docs/notebooks/example.ipynb",
280326
]
281-
282-
[tool.pixi]
283-
dependencies.python = ">=3.11"
284-
environments.dev-py311 = { features = [ "dev", "test", "py311" ], solve-group = "py311" }
285-
environments.docs-py311 = { features = [ "docs", "py311" ], solve-group = "py311" }
286-
environments.default = { features = [ "py313" ], solve-group = "py313" }
287-
environments.dev-py313 = { features = [ "dev", "test", "py313" ], solve-group = "py313" }
288-
environments.docs-py313 = { features = [ "docs", "py313" ], solve-group = "py313" }
289-
environments.test-py313 = { features = [ "test", "py313" ], solve-group = "py313" }
290-
feature.py311.dependencies.python = "3.11.*"
291-
feature.py313.dependencies.python = "3.13.*"
292-
pypi-dependencies.squidpy = { path = ".", editable = true }
293-
tasks.lab = "jupyter lab"
294-
tasks.kernel-install = 'python -m ipykernel install --user --name pixi-dev --display-name "squidpy (dev)"'
295-
tasks.test = "pytest -v --color=yes --tb=short --durations=10"
296-
tasks.lint = "ruff check ."
297-
tasks.format = "ruff format ."
298-
tasks.pre-commit-install = "pre-commit install"
299-
tasks.pre-commit = "pre-commit run"
300-
workspace.channels = [ "conda-forge" ]
301-
workspace.platforms = [ "osx-arm64", "linux-64" ]

src/squidpy/gr/_ligrec.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
_assert_categorical_obs,
2626
_assert_positive,
2727
_check_tuple_needles,
28+
_create_sparse_df,
2829
_genesymbols,
2930
_save_data,
3031
)
@@ -211,7 +212,7 @@ def __init__(self, adata: AnnData, use_raw: bool = True):
211212

212213
self._data = pd.DataFrame.sparse.from_spmatrix(
213214
csc_matrix(adata.X), index=adata.obs_names, columns=adata.var_names
214-
).fillna(0.0)
215+
)
215216

216217
self._interactions: pd.DataFrame | None = None
217218
self._filtered_data: pd.DataFrame | None = None
@@ -425,16 +426,18 @@ def test(
425426
numba_parallel=numba_parallel,
426427
**kwargs,
427428
)
428-
index = pd.MultiIndex.from_frame(interactions, names=[SOURCE, TARGET])
429-
columns = pd.MultiIndex.from_tuples(clusters, names=["cluster_1", "cluster_2"])
430429
res = {
431-
"means": pd.DataFrame(
432-
{c: pd.arrays.SparseArray(res.means[:, i], fill_value=0) for i, c in enumerate(columns)},
433-
index=index,
430+
"means": _create_sparse_df(
431+
res.means,
432+
index=pd.MultiIndex.from_frame(interactions, names=[SOURCE, TARGET]),
433+
columns=pd.MultiIndex.from_tuples(clusters, names=["cluster_1", "cluster_2"]),
434+
fill_value=0,
434435
),
435-
"pvalues": pd.DataFrame(
436-
{c: pd.arrays.SparseArray(res.pvalues[:, i], fill_value=np.nan) for i, c in enumerate(columns)},
437-
index=index,
436+
"pvalues": _create_sparse_df(
437+
res.pvalues,
438+
index=pd.MultiIndex.from_frame(interactions, names=[SOURCE, TARGET]),
439+
columns=pd.MultiIndex.from_tuples(clusters, names=["cluster_1", "cluster_2"]),
440+
fill_value=np.nan,
438441
),
439442
"metadata": self.interactions[self.interactions.columns.difference([SOURCE, TARGET])],
440443
}
@@ -735,11 +738,8 @@ def extractor(res: Sequence[TempResult]) -> TempResult:
735738

736739
return TempResult(means=means, pvalues=pvalues)
737740

738-
clustering = np.array(data["clusters"].values, dtype=np.int32)
739-
# densify the data earlier to avoid concatenating sparse arrays
740-
# with multiple fill values: '[0.0, nan]' (which leads to PerformanceWarning)
741-
data = data.astype({c: np.float64 for c in data.columns if c != "clusters"})
742741
groups = data.groupby("clusters", observed=True)
742+
clustering = np.array(data["clusters"].values, dtype=np.int32)
743743

744744
mean = groups.mean().values.T # (n_genes, n_clusters)
745745
# see https://github.com/scverse/squidpy/pull/991#issuecomment-2888506296

src/squidpy/gr/_niche.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def calculate_niche(
245245
for col in result_columns:
246246
if col in lib_result.obs.columns:
247247
prefixed_values = lib_result.obs[col].apply(
248-
lambda x, lib=lib_id: f"lib={lib}_{x}" if x != "not_a_niche" else x
248+
lambda x, lib=lib_id: (f"lib={lib}_{x}" if x != "not_a_niche" else x)
249249
)
250250

251251
adata.obs.loc[lib_indices, col] = prefixed_values.values

0 commit comments

Comments
 (0)