Skip to content

Commit

Permalink
XFail lobpcg with small test data (#2745)
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed Nov 10, 2023
1 parent d1a2c8f commit 8369414
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -107,7 +107,7 @@ test-full = [
]
doc = [
"sphinx>=5",
"sphinx-book-theme",
"sphinx-book-theme>=1.0.1",
"scanpydoc>=0.9.5",
"sphinx-autodoc-typehints",
"myst-parser",
Expand Down
15 changes: 13 additions & 2 deletions scanpy/tests/test_pca.py
@@ -1,3 +1,4 @@
from typing import Literal
import numpy as np
import pytest
import warnings
Expand Down Expand Up @@ -71,7 +72,9 @@ def zero_center(request: pytest.FixtureRequest):


@pytest.fixture
def pca_params(array_type, svd_solver_type, zero_center):
def pca_params(
array_type, svd_solver_type: Literal[None, "valid", "invalid"], zero_center
):
all_svd_solvers = {"auto", "full", "arpack", "randomized", "tsqr", "lobpcg"}

expected_warning = None
Expand Down Expand Up @@ -120,7 +123,9 @@ def test_pca_warnings(array_type, zero_center, pca_params):
if expected_warning is not None:
with pytest.warns(UserWarning, match=expected_warning):
sc.pp.pca(adata, svd_solver=svd_solver, zero_center=zero_center)
else:
return

try:
with warnings.catch_warnings():
warnings.simplefilter("error")
warnings.filterwarnings(
Expand All @@ -129,6 +134,12 @@ def test_pca_warnings(array_type, zero_center, pca_params):
DeprecationWarning,
)
sc.pp.pca(adata, svd_solver=svd_solver, zero_center=zero_center)
except UserWarning:
# TODO: Fix this case, maybe by increasing test data size.
# https://github.com/scverse/scanpy/issues/2744
if svd_solver == "lobpcg":
pytest.xfail(reason="lobpcg doesn’t work with this small test data")
raise


# This warning test is out of the fixture because it is a special case in the logic of the function
Expand Down

0 comments on commit 8369414

Please sign in to comment.