Skip to content

Commit b5e9933

Browse files
michalk8afuetterer
andauthored
Fix adata copy (coarse transition matrix) (#1223)
* chore: bump ruff pre-commit hook version * Fix copy * Fix some warnings * Fix reading from adata * Test on 3.12 * Update tox * Use `macos-14` * Drop 3.8 support * Update pre-commits * Update tests (pre-commit) * Run more pre-commits * Fix more pre-commits * Switch mostly to `np.random.default_rng` * Fix rest of the pre-commits * Update ruff version * Use 3.9 type-hints * Update black-docs * Fix workflow Python version * Try setting up conda on MacOS * Fix if statement * Use `observed=False` * Update test figure * Fix test on 3.12 * Unpin pytest version * Remove `worker_id` * Regenerate GT figures * Regenerate rest of the figures * Fix seeds in log_odds tests * Update `cluster_lineage` figures * Fix GAMR in failed model * Reduce CI verbosity * Run `format-references` * Polish `cite.rst` * Fix extra `clustering_kwargs` --------- Co-authored-by: Heinz-Alexander Fuetterer <[email protected]>
1 parent fb4e89a commit b5e9933

File tree

380 files changed

+560
-613
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

380 files changed

+560
-613
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ jobs:
3131
python-version: '3.10'
3232

3333
- name: Cache pre-commit
34-
uses: actions/cache@v4
3534
if: ${{ matrix.lint-kind == 'code' }}
35+
uses: actions/cache@v4
3636
with:
3737
path: ~/.cache/pre-commit
3838
key: pre-commit-${{ env.pythonLocation }}-${{ hashFiles('**/.pre-commit-config.yaml') }}

.github/workflows/test.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
os: [ubuntu-latest]
22-
python: ['3.8', '3.10', '3.11']
22+
python: ['3.9', '3.10', '3.11', '3.12']
2323
slepc: [noslepc]
2424
include:
25-
- os: macos-latest
26-
python: '3.9'
25+
- os: macos-14
26+
python: '3.10'
2727
slepc: noslepc
2828
- os: ubuntu-latest
2929
python: '3.10'
@@ -41,11 +41,17 @@ jobs:
4141
python -m pip install --upgrade pip
4242
python -m pip install tox
4343
44+
- name: Setup Conda
45+
if: runner.os == 'macOS'
46+
uses: conda-incubator/setup-miniconda@v3
47+
with:
48+
auto-update-conda: true
49+
4450
- name: Test
4551
run: |
46-
tox -e py${{ matrix.python }}-${{ matrix.slepc }} -vv
52+
tox -e py${{ matrix.python }}-${{ matrix.slepc }} -v
4753
env:
48-
PYTEST_ADDOPTS: -vv
54+
PYTEST_ADDOPTS: -v
4955

5056
- name: Upload coverage
5157
uses: codecov/codecov-action@v4

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,6 @@ docs/api/_autosummary
168168

169169
# tests
170170
tests/figures
171+
172+
# Ruff
173+
.ruff_cache

.pre-commit-config.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ default_stages:
77
minimum_pre_commit_version: 3.0.0
88
repos:
99
- repo: https://github.com/psf/black
10-
rev: 23.3.0
10+
rev: 24.8.0
1111
hooks:
1212
- id: black
1313
additional_dependencies: [toml]
1414
- repo: https://github.com/timothycrosley/isort
15-
rev: 5.12.0
15+
rev: 5.13.2
1616
hooks:
1717
- id: isort
1818
additional_dependencies: [toml]
1919
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
20-
rev: v2.9.0
20+
rev: v2.14.0
2121
hooks:
2222
- id: pretty-format-yaml
2323
args: [--autofix, --indent, '2']
2424
- repo: https://github.com/pre-commit/pre-commit-hooks
25-
rev: v4.4.0
25+
rev: v4.6.0
2626
hooks:
2727
- id: check-merge-conflict
2828
- id: check-ast
@@ -37,27 +37,27 @@ repos:
3737
- id: check-yaml
3838
- id: check-toml
3939
- repo: https://github.com/asottile/pyupgrade
40-
rev: v3.4.0
40+
rev: v3.17.0
4141
hooks:
4242
- id: pyupgrade
4343
args: [--py3-plus, --py38-plus, --keep-runtime-typing]
4444
- repo: https://github.com/asottile/blacken-docs
45-
rev: 1.13.0
45+
rev: 1.18.0
4646
hooks:
4747
- id: blacken-docs
48-
additional_dependencies: [black==23.1.0]
48+
additional_dependencies: [black==24.8.0]
4949
- repo: https://github.com/rstcheck/rstcheck
50-
rev: v6.1.2
50+
rev: v6.2.4
5151
hooks:
5252
- id: rstcheck
5353
additional_dependencies: [tomli]
5454
args: [--config=pyproject.toml]
5555
- repo: https://github.com/PyCQA/doc8
56-
rev: v1.1.1
56+
rev: v1.1.2
5757
hooks:
5858
- id: doc8
59-
- repo: https://github.com/charliermarsh/ruff-pre-commit
60-
rev: v0.0.270
59+
- repo: https://github.com/astral-sh/ruff-pre-commit
60+
rev: v0.6.5
6161
hooks:
6262
- id: ruff
6363
args: [--fix, --exit-non-zero-on-fix]

docs/_ext/typed_returns.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import re
2-
from typing import Iterable, Iterator, List
2+
from collections.abc import Iterable, Iterator
33

44
from sphinx.application import Sphinx
55
from sphinx.ext.napoleon import NumpyDocstring
@@ -18,9 +18,9 @@ def process_return(lines: Iterable[str]) -> Iterator[str]:
1818
yield line
1919

2020

21-
def _parse_returns_section(self: NumpyDocstring, section: str) -> List[str]:
21+
def _parse_returns_section(self: NumpyDocstring, section: str) -> list[str]:
2222
lines_raw = list(process_return(self._dedent(self._consume_to_next_section())))
23-
lines: List[str] = self._format_block(":returns: ", lines_raw)
23+
lines: list[str] = self._format_block(":returns: ", lines_raw)
2424
if lines and lines[-1]:
2525
lines.append("")
2626
return lines

docs/about/cite.rst

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ CellRank's :class:`~cellrank.kernels.VelocityKernel` with classical RNA velocity
66
.. code-block:: bibtex
77
88
@article{lange:22,
9-
title = {CellRank for directed single-cell fate mapping},
10-
author = {Lange, Marius and Bergen, Volker and Klein, Michal and Setty, Manu and
11-
Reuter, Bernhard and Bakhti, Mostafa and Lickert, Heiko and
12-
Ansari, Meshal and Schniering, Janine and Schiller, Herbert B. and
13-
Pe'er, Dana and Theis, Fabian J.},
14-
journal = {Nat. Methods},
15-
year = {2022},
16-
doi = {10.1038/s41592-021-01346-6},
17-
publisher = {Nature Publishing Group}
9+
author = {Lange, Marius and Bergen, Volker and Klein, Michal and Setty, Manu and Reuter, Bernhard and Bakhti, Mostafa and Lickert, Heiko and Ansari, Meshal and Schniering, Janine and Schiller, Herbert B. and Pe'er, Dana and Theis, Fabian J.},
10+
publisher = {Nature Publishing Group},
11+
doi = {10.1038/s41592-021-01346-6},
12+
journal = {Nat. Methods},
13+
title = {CellRank for directed single-cell fate mapping},
14+
year = {2022},
1815
}
1916
2017
If you are using the :class:`~cellrank.kernels.PseudotimeKernel`, :class:`~cellrank.kernels.CytoTRACEKernel`, :class:`~cellrank.kernels.RealTimeKernel`, or the :class:`~cellrank.kernels.VelocityKernel` with velocities inferred
@@ -23,15 +20,18 @@ from metabolic labeling data using the CellRank 2 approach, cite :cite:`weiler:2
2320
.. code-block:: bibtex
2421
2522
@article{weiler:24,
26-
title = {CellRank 2: unified fate mapping in multiview single-cell data},
27-
author = {Weiler, Philipp and Lange, Marius and Klein, Michal and Pe{\textquotesingle}er, Dana and Theis, Fabian},
28-
doi = {10.1038/s41592-024-02303-9},
29-
url = {https://doi.org/10.1038/s41592-024-02303-9},
30-
year = {2024},
31-
journal = {Nature Methods},
32-
volume = {21},
33-
number = {7},
34-
pages = {1196--1205},
23+
author = {Weiler, Philipp and Lange, Marius and Klein, Michal and Pe'er, Dana and Theis, Fabian},
24+
publisher = {Springer Science and Business Media LLC},
25+
url = {https://doi.org/10.1038/s41592-024-02303-9},
26+
doi = {10.1038/s41592-024-02303-9},
27+
issn = {1548-7105},
28+
journal = {Nature Methods},
29+
month = jun,
30+
number = {7},
31+
pages = {1196--1205},
32+
title = {CellRank 2: unified fate mapping in multiview single-cell data},
33+
volume = {21},
34+
year = {2024},
3535
}
3636
3737
In addition, if you use the :class:`~cellrank.estimators.GPCCA` estimator to compute initial, terminal or intermediate
@@ -42,12 +42,12 @@ please cite GPCCA :cite:`reuter:19` as:
4242
.. code-block:: bibtex
4343
4444
@article{reuter:19,
45-
author = {Reuter,Bernhard and Fackeldey,Konstantin and Weber,Marcus },
46-
title = {Generalized Markov modeling of nonreversible molecular kinetics},
47-
journal = {The Journal of Chemical Physics},
48-
volume = {150},
49-
number = {17},
50-
pages = {174103},
51-
year = {2019},
52-
doi = {10.1063/1.5064530},
45+
author = {Reuter, Bernhard and Fackeldey, Konstantin and Weber, Marcus},
46+
doi = {10.1063/1.5064530},
47+
journal = {The Journal of Chemical Physics},
48+
number = {17},
49+
pages = {174103},
50+
title = {Generalized Markov modeling of nonreversible molecular kinetics},
51+
volume = {150},
52+
year = {2019},
5353
}

docs/notebooks

docs/references.bib

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -804,16 +804,16 @@ @article{bastidas:17
804804
}
805805

806806
@article{weiler:24,
807-
title = {CellRank 2: unified fate mapping in multiview single-cell data},
808-
volume = {21},
809-
ISSN = {1548-7105},
810-
url = {http://dx.doi.org/10.1038/s41592-024-02303-9},
811-
DOI = {10.1038/s41592-024-02303-9},
812-
number = {7},
813-
journal = {Nature Methods},
814-
publisher = {Springer Science and Business Media LLC},
815-
author = {Weiler, Philipp and Lange, Marius and Klein, Michal and Pe'er, Dana and Theis, Fabian},
816-
year = {2024},
817-
month = jun,
818-
pages = {1196--1205}
807+
author = {Weiler, Philipp and Lange, Marius and Klein, Michal and Pe'er, Dana and Theis, Fabian},
808+
publisher = {Springer Science and Business Media LLC},
809+
url = {http://dx.doi.org/10.1038/s41592-024-02303-9},
810+
doi = {10.1038/s41592-024-02303-9},
811+
issn = {1548-7105},
812+
journal = {Nature Methods},
813+
month = jun,
814+
number = {7},
815+
pages = {1196--1205},
816+
title = {CellRank 2: unified fate mapping in multiview single-cell data},
817+
volume = {21},
818+
year = {2024},
819819
}

pyproject.toml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "cellrank"
77
dynamic = ["version"]
88
description = "CellRank: dynamics from multi-view single-cell data"
99
readme = "README.rst"
10-
requires-python = ">=3.8"
10+
requires-python = ">=3.9"
1111
license = {file = "LICENSE"}
1212
classifiers = [
1313
"Development Status :: 5 - Production/Stable",
@@ -19,10 +19,10 @@ classifiers = [
1919
"Operating System :: Microsoft :: Windows",
2020
"Typing :: Typed",
2121
"Programming Language :: Python :: 3",
22-
"Programming Language :: Python :: 3.8",
2322
"Programming Language :: Python :: 3.9",
2423
"Programming Language :: Python :: 3.10",
2524
"Programming Language :: Python :: 3.11",
25+
"Programming Language :: Python :: 3.12",
2626
"Topic :: Scientific/Engineering :: Bio-Informatics",
2727
"Topic :: Scientific/Engineering :: Mathematics",
2828
"Topic :: Scientific/Engineering :: Visualization",
@@ -69,8 +69,7 @@ dev = [
6969
"tox>=4",
7070
]
7171
test = [
72-
"pytest>=7,<8.1.0",
73-
"pytest-xdist>=3",
72+
"pytest>=8",
7473
"pytest-mock>=3.5.0",
7574
"pytest-cov>=4",
7675
"coverage[toml]>=7",
@@ -106,7 +105,10 @@ include-package-data = true
106105
[tool.setuptools_scm]
107106

108107
[tool.ruff]
109-
target-version = "py38"
108+
target-version = "py39"
109+
line-length = 120
110+
111+
[tool.ruff.lint]
110112
exclude = [
111113
".eggs",
112114
".git",
@@ -136,7 +138,6 @@ ignore = [
136138
# Missing docstring in magic method
137139
"D105",
138140
]
139-
line-length = 120
140141
select = [
141142
"D", # flake8-docstrings
142143
"E", # pycodestyle
@@ -154,21 +155,21 @@ select = [
154155
"T20", # flake8-print
155156
"RET", # flake8-raise
156157
]
157-
unfixable = ["B", "UP", "C4", "BLE", "T20", "RET"]
158-
[tool.ruff.per-file-ignores]
158+
unfixable = ["B", "C4", "BLE", "T20", "RET"]
159+
[tool.ruff.lint.per-file-ignores]
159160
"tests/*" = ["D"]
160161
"*/__init__.py" = ["F401"]
161162
"docs/*" = ["D"]
162-
[tool.ruff.pydocstyle]
163+
[tool.ruff.lint.pydocstyle]
163164
convention = "numpy"
164-
[tool.ruff.flake8-tidy-imports]
165+
[tool.ruff.lint.flake8-tidy-imports]
165166
ban-relative-imports = "all"
166-
[tool.ruff.flake8-quotes]
167+
[tool.ruff.lint.flake8-quotes]
167168
inline-quotes = "double"
168169

169170
[tool.black]
170171
line-length = 120
171-
target-version = ['py38']
172+
target-version = ['py39']
172173
include = '\.pyi?$'
173174

174175
[tool.isort]
@@ -237,7 +238,7 @@ legacy_tox_ini = """
237238
# TODO(michalk8): upgrade to `tox>=4.0` once `tox-conda` supports it
238239
requires = tox-conda
239240
isolated_build = true
240-
envlist = lint-code,py{3.8,3.9,3.10,3.11}-{slepc,noslepc}
241+
envlist = lint-code,py{3.9,3.10,3.11,3.12}-{slepc,noslepc}
241242
skip_missing_interpreters = true
242243
243244
[testenv]

src/cellrank/_utils/_colors.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, List, Optional, Sequence, Tuple, Union
1+
from collections.abc import Sequence
2+
from typing import Any, Optional, Union
23

34
import numpy as np
45
import pandas as pd
@@ -11,14 +12,14 @@
1112

1213

1314
def _create_colors(
14-
base_color: Union[str, Tuple[float, float, float]],
15+
base_color: Union[str, tuple[float, float, float]],
1516
n: int,
16-
hue_range: Optional[Tuple[float, float]] = (-0.1, 0.1),
17-
saturation_range: Optional[Tuple[float, float]] = (-0.3, 0.3),
18-
value_range: Optional[Tuple[float, float]] = (-0.3, 0.3),
17+
hue_range: Optional[tuple[float, float]] = (-0.1, 0.1),
18+
saturation_range: Optional[tuple[float, float]] = (-0.3, 0.3),
19+
value_range: Optional[tuple[float, float]] = (-0.3, 0.3),
1920
convert_to_rgb: bool = True,
2021
as_hex: bool = True,
21-
) -> List[Any]:
22+
) -> list[Any]:
2223
"""Create variations of colors from base color.
2324
2425
Parameters
@@ -74,7 +75,7 @@ def _create_colors(
7475
return res[::2] # we've created twice as many colors, select every other
7576

7677

77-
def _convert_to_hex_colors(cols: Sequence[Any]) -> List[str]:
78+
def _convert_to_hex_colors(cols: Sequence[Any]) -> list[str]:
7879
if not all(colors.is_color_like(c) for c in cols):
7980
raise ValueError("Not all values are color-like.")
8081

@@ -108,7 +109,7 @@ def _create_categorical_colors(n_categories: Optional[int] = None):
108109
raise RuntimeError(f"Unable to create `{n_categories}` colors.")
109110

110111

111-
def _insert_categorical_colors(seen_colors: Union[np.ndarray, List], n_categories: int):
112+
def _insert_categorical_colors(seen_colors: Union[np.ndarray, list], n_categories: int):
112113
seen_colors = set(_convert_to_hex_colors(seen_colors))
113114
candidates = list(filter(lambda c: c not in seen_colors, _create_categorical_colors()))[:n_categories]
114115

@@ -135,7 +136,7 @@ def _get_black_or_white(value: float, cmap) -> str:
135136
return _contrasting_color(r, g, b)
136137

137138

138-
def _get_bg_fg_colors(color, sat_scale: Optional[float] = None) -> Tuple[str, str]:
139+
def _get_bg_fg_colors(color, sat_scale: Optional[float] = None) -> tuple[str, str]:
139140
if not colors.is_color_like(color):
140141
raise ValueError(f"Value `{color}` is not color-like.")
141142

@@ -155,7 +156,7 @@ def _map_names_and_colors(
155156
series_query: pd.Series,
156157
colors_reference: Optional[np.array] = None,
157158
en_cutoff: Optional[float] = None,
158-
) -> Union[pd.Series, Tuple[pd.Series, List[Any]]]:
159+
) -> Union[pd.Series, tuple[pd.Series, list[Any]]]:
159160
"""Map annotations and colors from one series to another.
160161
161162
Parameters
@@ -270,7 +271,7 @@ def _map_names_and_colors(
270271
return (names_query_new, list(_convert_to_hex_colors(colors_query_new))) if process_colors else names_query_new
271272

272273

273-
def _compute_mean_color(cols: List[str]) -> str:
274+
def _compute_mean_color(cols: list[str]) -> str:
274275
"""Compute mean color."""
275276
if not all(colors.is_color_like(c) for c in cols):
276277
raise ValueError(f"Not all values are valid colors `{cols}`.")

0 commit comments

Comments
 (0)