Skip to content

Commit

Permalink
Speed up tests (#601)
Browse files Browse the repository at this point in the history
* Start 0.8.0

Signed-off-by: zethson <[email protected]>

* Speed up tests and fix some warnings

Signed-off-by: zethson <[email protected]>

* Fix augur test

Signed-off-by: zethson <[email protected]>

* Further speed up tests and introduce new profile

Signed-off-by: zethson <[email protected]>

* Proper strategy syntax

Signed-off-by: zethson <[email protected]>

* Readd fast profile

Signed-off-by: zethson <[email protected]>

* Readd fast profile

Signed-off-by: zethson <[email protected]>

---------

Signed-off-by: zethson <[email protected]>
  • Loading branch information
Zethson authored May 21, 2024
1 parent 6d3ec7e commit 72e0864
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ jobs:
include:
- os: ubuntu-latest
python: "3.10"
run_mode: "slow"
- os: ubuntu-latest
python: "3.11"
run_mode: "slow"
- os: ubuntu-latest
python: "3.11"
run_mode: "fast"
- os: ubuntu-latest
python: "3.11"
run_mode: slow
pip-flags: "--pre"

env:
Expand All @@ -52,7 +58,12 @@ jobs:
MPLBACKEND: agg
PLATFORM: ${{ matrix.os }}
DISPLAY: :42
run: coverage run -m pytest -v --color=yes --runslow
run: |
pytest_args="-m pytest -v --color=yes"
if [ "${{ matrix.run_mode }}" = "slow" ]; then
pytest_args="$pytest_args --runslow"
fi
coverage run $pytest_args
- name: Show coverage report
run: coverage report -m
Expand Down
1 change: 1 addition & 0 deletions tests/metadata/test_cell_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def test_protein_expression_annotation(adata):
)


@pytest.mark.slow
def test_bulk_rna_expression_annotation(adata):
pt_metadata.annotate(adata)
pt_metadata.annotate_bulk_rna(adata, query_id="DepMap_ID", cell_line_source="broad")
Expand Down
1 change: 1 addition & 0 deletions tests/tools/_coda/test_sccoda.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def test_credible_effects(adata):
assert sccoda.credible_effects(mdata)["condition[T.Salmonella]"]["Enterocyte"]


@pytest.mark.slow
def test_make_arviz(adata):
adata_salm = adata[adata.obs["condition"].isin(["Control", "Salmonella"])]
mdata = sccoda.load(
Expand Down
9 changes: 6 additions & 3 deletions tests/tools/_distances/test_distance_tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pertpy as pt
import pytest
import scanpy as sc
from pandas import DataFrame
from pytest import fixture, mark

distances = [
"edistance",
Expand All @@ -27,16 +27,19 @@
count_distances = ["nb_ll"]


@fixture
@pytest.fixture
def adata():
adata = pt.dt.distance_example()
adata = sc.pp.subsample(adata, 0.1, copy=True)

return adata


@mark.parametrize("distance", distances)
@pytest.mark.parametrize("distance", distances)
def test_distancetest(adata, distance):
if distance == "wasserstein":
pytest.mark.apply(pytest.mark.slow)

etest = pt.tl.DistanceTest(distance, n_perms=10, obsm_key="X_pca", alpha=0.05, correction="holm-sidak")
tab = etest(adata, groupby="perturbation", contrast="control")

Expand Down
1 change: 1 addition & 0 deletions tests/tools/test_augur.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def test_differential_prioritization():
"""Test differential prioritization run."""
# Requires the full dataset or it fails because of a lack of statistical power
adata = pt.dt.sc_sim_augur()
adata = sc.pp.subsample(adata, n_obs=500, copy=True, random_state=10)
ag = pt.tl.Augur("random_forest_classifier", Params(random_state=42))
ag.load(adata)

Expand Down
6 changes: 3 additions & 3 deletions tests/tools/test_mixscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
import numpy as np
import pandas as pd
import pertpy as pt
from _pytest.fixtures import fixture
import pytest
from scipy import sparse

CWD = Path(__file__).parent.resolve()

# Random generate data settings
num_cells_per_group = 100
num_cells_per_group = 10
num_not_de = 10
num_de = 10
accuracy_threshold = 0.8


@fixture
@pytest.fixture
def adata():
rng = np.random.default_rng(seed=1)
# generate not differentially expressed genes
Expand Down

0 comments on commit 72e0864

Please sign in to comment.