Skip to content

Commit

Permalink
Simplify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zethson committed Sep 16, 2023
1 parent 8389f89 commit f912114
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Binary file removed tests/tools/cinemaot.h5ad
Binary file not shown.
Binary file removed tests/tools/mixscape.h5ad
Binary file not shown.
14 changes: 6 additions & 8 deletions tests/tools/test_mixscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np
import pandas as pd
import pertpy as pt
from _pytest.fixtures import fixture
from scipy import sparse

CWD = Path(__file__).parent.resolve()
Expand All @@ -16,7 +17,8 @@


class TestMixscape:
def make_test_adata(self):
@fixture
def adata(self):
np.random.seed(1)
# generate not differentially expressed genes
for i in range(num_not_de):
Expand Down Expand Up @@ -64,8 +66,7 @@ def make_test_adata(self):
adata = anndata.AnnData(X=X, obs=obs, var=var, dtype=np.float32)
return adata

def test_mixscape(self):
adata = self.make_test_adata()
def test_mixscape(self, adata):
mixscape_identifier = pt.tl.Mixscape()
adata.layers["X_pert"] = adata.X
mixscape_identifier.mixscape(adata=adata, control="NT", labels="gene_target")
Expand All @@ -81,16 +82,13 @@ def test_mixscape(self):
assert sum(np_result_correct) > accuracy_threshold * num_cells_per_group
assert sum(ko_result_correct) > accuracy_threshold * num_cells_per_group

def test_perturbation_signature(self):
adata = self.make_test_adata()

def test_perturbation_signature(self, adata):
mixscape_identifier = pt.tl.Mixscape()
mixscape_identifier.perturbation_signature(adata, pert_key="label", control="control")

assert "X_pert" in adata.layers

def test_lda(self):
adata = self.make_test_adata()
def test_lda(self, adata):
adata.layers["X_pert"] = adata.X
mixscape_identifier = pt.tl.Mixscape()
mixscape_identifier.mixscape(adata=adata, control="NT", labels="gene_target")
Expand Down

0 comments on commit f912114

Please sign in to comment.