Skip to content

Commit ca27acd

Browse files
fixed some unit tests
1 parent 3fd95a4 commit ca27acd

File tree

4 files changed

+14
-29
lines changed

4 files changed

+14
-29
lines changed

diffxpy/unit_test/test_continuous.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_null_distribution_wald(self, n_cells: int = 2000, n_genes: int = 100):
8080
:param n_cells: Number of cells to simulate (number of observations per test).
8181
:param n_genes: Number of genes to simulate (number of tests).
8282
"""
83-
logging.getLogger("tensorflow").setLevel(logging.INFO)
83+
logging.getLogger("tensorflow").setLevel(logging.ERROR)
8484
logging.getLogger("batchglm").setLevel(logging.WARNING)
8585
logging.getLogger("diffxpy").setLevel(logging.WARNING)
8686

diffxpy/unit_test/test_numeric.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import unittest
22

33
import numpy as np
4-
import pandas as pd
5-
import scipy.stats as stats
64
import logging
75

86
from batchglm.api.models.glm_nb import Simulator

diffxpy/unit_test/test_pairwise.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pandas as pd
55
import scipy.stats as stats
66

7-
from batchglm.api.models.glm_nb import Simulator, Estimator, InputData
7+
from batchglm.api.models.glm_nb import Simulator
88
import diffxpy.api as de
99

1010

@@ -247,18 +247,21 @@ def test_ztest_de(self, n_cells: int = 2000, n_genes: int = 500):
247247
)
248248
summary = test.summary()
249249

250+
frac_nonde_sig = np.mean(
251+
np.sum(test.qval[~np.eye(test.pval.shape[0]).astype(bool), :num_non_de] < 0.05) /
252+
(2 * num_non_de)
253+
)
254+
frac_de_sig = np.mean(
255+
np.sum(test.qval[~np.eye(test.pval.shape[0]).astype(bool), num_non_de:] < 0.05) /
256+
(2 * (n_genes - num_non_de))
257+
)
250258
logging.getLogger("diffxpy").info('fraction of non-DE genes with q-value < 0.05: %.1f%%' %
251-
float(100 * np.mean(
252-
np.sum(test.qval[~np.eye(test.pval.shape[0]).astype(bool), :num_non_de] < 0.05) /
253-
(2 * num_non_de)
254-
)))
259+
str(np.round(100. * frac_nonde_sig, 3)))
255260
logging.getLogger("diffxpy").info('fraction of DE genes with q-value < 0.05: %.1f%%' %
256-
float(100 * np.mean(
257-
np.sum(test.qval[~np.eye(test.pval.shape[0]).astype(bool), num_non_de:] < 0.05) /
258-
(2 * (n_genes - num_non_de))
259-
)))
261+
str(np.round(100. * frac_de_sig, 3)))
260262

261-
# TODO asserts
263+
assert frac_de_sig > 0.5, "too many DE"
264+
assert frac_nonde_sig < 0.5, "too many non-DE"
262265
return True
263266

264267

diffxpy/unit_test/test_single_training_strategies.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)