diff --git a/docs/tutorials/notebooks b/docs/tutorials/notebooks index 5c93d2c2..42d7ee0f 160000 --- a/docs/tutorials/notebooks +++ b/docs/tutorials/notebooks @@ -1 +1 @@ -Subproject commit 5c93d2c2dc686da7c78d1c79f7b299d35e22edf2 +Subproject commit 42d7ee0fb8ede8167d65b577526af895e78a2436 diff --git a/pertpy/tools/_augur.py b/pertpy/tools/_augur.py index 41590653..9f1573fd 100644 --- a/pertpy/tools/_augur.py +++ b/pertpy/tools/_augur.py @@ -230,7 +230,12 @@ def create_estimator( random_state=random_state, ) elif classifier == "logistic_regression_classifier": - return LogisticRegression(penalty=penalty, random_state=random_state) + # scikit-learn 1.8 deprecated `penalty` in favor of `l1_ratio` (the L1/L2 mix) and `C` (no penalty via C=inf). + if penalty in (None, "none"): + return LogisticRegression(C=np.inf, random_state=random_state) + l1_ratio = {"l2": 0.0, "l1": 1.0, "elasticnet": 0.5}[penalty] + solver = "saga" if l1_ratio > 0.0 else "lbfgs" + return LogisticRegression(l1_ratio=l1_ratio, solver=solver, random_state=random_state) else: raise ValueError("Invalid classifier") diff --git a/pyproject.toml b/pyproject.toml index ed86d47c..2d646bd1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -175,7 +175,14 @@ filterwarnings = [ "ignore:'cgi' is deprecated and slated for removal in Python 3.13:DeprecationWarning", "ignore:In the future, the default backend for leiden will be igraph instead of leidenalg:FutureWarning", "ignore:Transforming to str index:anndata.ImplicitModificationWarning", - "ignore:Failed to correctly find n_neighbors for some samples:UserWarning" + "ignore:Failed to correctly find n_neighbors for some samples:UserWarning", + # pydeseq2 emits these on the small synthetic data used by the Milo and compare_groups tests; they are not actionable in pertpy. + "ignore:The dispersion trend curve fitting did not converge:UserWarning", + "ignore:As the residual degrees of freedom is less than 3:UserWarning", + # Third-party deprecation and runtime notices that pertpy cannot resolve at the source. + "ignore:JAXopt is no longer maintained:DeprecationWarning", + "ignore:A worker stopped while some jobs were given to the executor:UserWarning", + "ignore:Data has categories outside of the nominated levels" ] [tool.hatch.envs.default] diff --git a/tests/tools/_differential_gene_expression/test_statsmodels.py b/tests/tools/_differential_gene_expression/test_statsmodels.py index f5ea1264..05b76983 100644 --- a/tests/tools/_differential_gene_expression/test_statsmodels.py +++ b/tests/tools/_differential_gene_expression/test_statsmodels.py @@ -8,7 +8,9 @@ pytestmark = pytest.mark.skip(reason="formulaic_contrasts and formulaic not available") -@pytest.mark.parametrize("kwargs", [{}, {"regression_model": sm.GLM, "family": sm.families.NegativeBinomial()}]) +@pytest.mark.parametrize( + "kwargs", [{}, {"regression_model": sm.GLM, "family": sm.families.NegativeBinomial(alpha=1.0)}] +) def test_statsmodels(test_adata, kwargs): """Check that the method can be initialized and fitted, and perform basic checks on the result of test_contrasts.""" from pertpy.tools._differential_gene_expression import Statsmodels diff --git a/tests/tools/_perturbation_space/test_simple_perturbation_space.py b/tests/tools/_perturbation_space/test_simple_perturbation_space.py index 8a1a1627..1396dc55 100644 --- a/tests/tools/_perturbation_space/test_simple_perturbation_space.py +++ b/tests/tools/_perturbation_space/test_simple_perturbation_space.py @@ -199,12 +199,14 @@ def test_linear_operations(): # Input that has already been differenced — opt out of the auto-diff with ensure_consistency=False. ps_adata = ps.compute_control_diff(psadata) - ps_adata2 = ps.add(ps_adata, perturbations=["target1", "target2"], ensure_consistency=False) + with pytest.warns(UserWarning, match="Combining perturbations without"): + ps_adata2 = ps.add(ps_adata, perturbations=["target1", "target2"], ensure_consistency=False) test = ps_adata["control"].X + ps_adata["target1"].X + ps_adata["target2"].X np.testing.assert_allclose(test, ps_adata2["target1+target2"].X, rtol=1e-4) - ps_adata2 = ps.subtract(ps_adata, reference_key="target1", perturbations=["target1"], ensure_consistency=False) + with pytest.warns(UserWarning, match="Combining perturbations without"): + ps_adata2 = ps.subtract(ps_adata, reference_key="target1", perturbations=["target1"], ensure_consistency=False) ps_vector = ps_adata2["target1-target1"].X np.testing.assert_allclose(ps_adata2["control"].X, ps_adata2["target1-target1"].X, rtol=1e-4)