Skip to content

Commit 41f80ba

Browse files
authored
ci: adapt tests to igraph 1.0 (#3868)
1 parent 0aec2ef commit 41f80ba

File tree

7 files changed

+13
-3
lines changed

7 files changed

+13
-3
lines changed

tests/_images/paga/expected.png

-2.26 KB
Loading
-2.66 KB
Loading
-3.78 KB
Loading
-2.75 KB
Loading
-3.01 KB
Loading

tests/test_clustering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_leiden_random_state(adata_neighbors, flavor):
6767
adata_2 = sc.tl.leiden(
6868
adata_neighbors,
6969
flavor=flavor,
70-
random_state=2,
70+
random_state=3,
7171
copy=True,
7272
directed=is_leiden_alg,
7373
n_iterations=n_iterations,

tests/test_paga.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
from __future__ import annotations
22

33
from functools import partial
4+
from importlib.util import find_spec
45
from pathlib import Path
56

67
import numpy as np
78
import pytest
89
from matplotlib import cm
10+
from packaging.version import Version
911

1012
import scanpy as sc
13+
from scanpy._compat import pkg_version
1114
from testing.scanpy._helpers.data import pbmc3k_processed, pbmc68k_reduced
1215
from testing.scanpy._pytest.marks import needs
1316

1417
HERE: Path = Path(__file__).parent
1518
ROOT = HERE / "_images"
1619

20+
SKIP_IF_OLD_IGRAPH = pytest.mark.skipif(
21+
not find_spec("igraph") or pkg_version("igraph") < Version("1"),
22+
reason="igraph 0.x has different RNG behavior",
23+
)
24+
1725

1826
pytestmark = [needs.igraph]
1927

@@ -32,6 +40,7 @@ def pbmc(pbmc_session):
3240
return pbmc_session.copy()
3341

3442

43+
@SKIP_IF_OLD_IGRAPH
3544
@pytest.mark.parametrize(
3645
("test_id", "func"),
3746
[
@@ -60,14 +69,15 @@ def test_paga_plots(image_comparer, pbmc, test_id, func):
6069
save_and_compare_images(f"paga_{test_id}" if test_id else "paga")
6170

6271

72+
@SKIP_IF_OLD_IGRAPH
6373
def test_paga_pie(image_comparer, pbmc) -> None:
6474
save_and_compare_images = partial(image_comparer, ROOT, tol=30)
6575

6676
colors = {
67-
c: {cm.Set1(_): 0.33 for _ in range(3)}
77+
c: {cm.Set1(i): 0.33 for i in range(3)}
6878
for c in pbmc.obs["bulk_labels"].cat.categories
6979
}
70-
colors["Dendritic"] = {cm.Set2(_): 0.25 for _ in range(4)}
80+
colors["Dendritic"] = {cm.Set2(i): 0.25 for i in range(4)}
7181

7282
sc.pl.paga(pbmc, color=colors, colorbar=False, show=False)
7383
save_and_compare_images("paga_pie")

0 commit comments

Comments
 (0)