Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into catplot-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
eroell committed Nov 10, 2023
2 parents 2600dc7 + 8369414 commit f5cdff8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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 f5cdff8

Please sign in to comment.