From 61af4c6c4f842f482cbd05dbe74787260fb569b6 Mon Sep 17 00:00:00 2001 From: Gert Hulselmans Date: Mon, 21 Nov 2022 11:59:03 +0100 Subject: [PATCH] Run black formatting on python test scripts. Run black formatting on python test scripts. --- tests/test_aucell.py | 18 +++++++++++++----- tests/test_featureseq.py | 22 +++++++++++----------- tests/test_math.py | 6 ++++-- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/tests/test_aucell.py b/tests/test_aucell.py index 12a4997..08beb19 100644 --- a/tests/test_aucell.py +++ b/tests/test_aucell.py @@ -8,18 +8,24 @@ from pyscenic.aucell import aucell, create_rankings, derive_auc_threshold NOMENCLATURE = "HGNC" -TEST_EXPRESSION_MTX_FNAME = resource_filename('resources.tests', "GSE103322.em.hgnc.sample.cxg.csv") -TEST_SIGNATURE_FNAME = resource_filename('resources.tests', "c6.all.v6.1.symbols.gmt") +TEST_EXPRESSION_MTX_FNAME = resource_filename( + "resources.tests", "GSE103322.em.hgnc.sample.cxg.csv" +) +TEST_SIGNATURE_FNAME = resource_filename("resources.tests", "c6.all.v6.1.symbols.gmt") @pytest.fixture def exp_matrix(): - return pd.read_csv(TEST_EXPRESSION_MTX_FNAME, sep=',', header=0, index_col=0) + return pd.read_csv(TEST_EXPRESSION_MTX_FNAME, sep=",", header=0, index_col=0) @pytest.fixture def gs(): - return GeneSignature.from_gmt(TEST_SIGNATURE_FNAME, gene_separator="\t", field_separator="\t", ) + return GeneSignature.from_gmt( + TEST_SIGNATURE_FNAME, + gene_separator="\t", + field_separator="\t", + ) def test_create_rankings(exp_matrix): @@ -41,6 +47,8 @@ def test_aucell_w2(exp_matrix, gs): def test_aucell_mismatch(exp_matrix, gs): percentiles = derive_auc_threshold(exp_matrix) - gss = [GeneSignature(name="test", gene2weight=list(map("FAKE{}".format, range(100))))] + gs + gss = [ + GeneSignature(name="test", gene2weight=list(map("FAKE{}".format, range(100)))) + ] + gs aucs_mtx = aucell(exp_matrix, gss, auc_threshold=percentiles[0.01], num_workers=1) print(aucs_mtx.head()) diff --git a/tests/test_featureseq.py b/tests/test_featureseq.py index 28564e0..befc9d3 100644 --- a/tests/test_featureseq.py +++ b/tests/test_featureseq.py @@ -5,10 +5,10 @@ def test_feature_overlap(): - f1 = Feature.from_string('chr1 12 50 feature1 10.0 +') - f2 = Feature.from_string('chr1 40 60 feature2 10.0 -') - f3 = Feature.from_string('chr1 60 80 feature2 10.0 -') - f4 = Feature.from_string('chr2 60 80 feature2 10.0 -') + f1 = Feature.from_string("chr1 12 50 feature1 10.0 +") + f2 = Feature.from_string("chr1 40 60 feature2 10.0 -") + f3 = Feature.from_string("chr1 60 80 feature2 10.0 -") + f4 = Feature.from_string("chr2 60 80 feature2 10.0 -") assert f1.has_overlap_with(f2) assert not f1.has_overlap_with(f3) assert not f3.has_overlap_with(f4) @@ -16,18 +16,18 @@ def test_feature_overlap(): def test_feature_contains(): - f1 = Feature.from_string('chr1 50 60 feature1 10.0 +') - f2 = Feature.from_string('chr1 40 60 feature2 10.0 -') - f3 = Feature.from_string('chr2 40 80 feature2 10.0 -') + f1 = Feature.from_string("chr1 50 60 feature1 10.0 +") + f2 = Feature.from_string("chr1 40 60 feature2 10.0 -") + f3 = Feature.from_string("chr2 40 80 feature2 10.0 -") assert f1 in f2 assert not f1 in f3 def test_feature_bp_overlap(): - f1 = Feature.from_string('chr1 12 50 feature1 10.0 +') - f2 = Feature.from_string('chr1 40 60 feature2 10.0 -') - f3 = Feature.from_string('chr1 60 80 feature2 10.0 -') - f4 = Feature.from_string('chr2 60 80 feature2 10.0 -') + f1 = Feature.from_string("chr1 12 50 feature1 10.0 +") + f2 = Feature.from_string("chr1 40 60 feature2 10.0 -") + f3 = Feature.from_string("chr1 60 80 feature2 10.0 -") + f4 = Feature.from_string("chr2 60 80 feature2 10.0 -") assert f1.get_overlap_in_bp_with(f2) == 10 assert f1.get_overlap_in_bp_with(f3) == 0 assert f2.get_overlap_in_bp_with(f3) == 0 diff --git a/tests/test_math.py b/tests/test_math.py index dea30c2..7a01f0a 100644 --- a/tests/test_math.py +++ b/tests/test_math.py @@ -9,5 +9,7 @@ def test_masked_rho(): x = np.array([1, 2, -1, 0.0, 4], dtype=float) y = np.array([1, 2, 0.0, -8, 4], dtype=float) - assert pytest.approx(masked_rho(x, y, 0.0), 0.00001) == \ - np.corrcoef(np.array([1.0, 2.0, 4.0]), np.array([1.0, 2.0, 4.0]))[0, 1] + assert ( + pytest.approx(masked_rho(x, y, 0.0), 0.00001) + == np.corrcoef(np.array([1.0, 2.0, 4.0]), np.array([1.0, 2.0, 4.0]))[0, 1] + )