diff options
author | Alexander Kabui | 2021-11-29 00:27:19 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-12-10 09:58:29 +0300 |
commit | bc1b310503d63555ffe9d2da0a881f11b666fa3b (patch) | |
tree | 95c692ac6f7f0c67ae80233351cf4a523c5c76f0 /tests | |
parent | d253a9bc5e4831da03df45c7b0b73ed4456853b9 (diff) | |
download | genenetwork3-bc1b310503d63555ffe9d2da0a881f11b666fa3b.tar.gz |
refactor sample r unittests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/computations/test_correlation.py | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/tests/unit/computations/test_correlation.py b/tests/unit/computations/test_correlation.py index 8b50f0e..0de347d 100644 --- a/tests/unit/computations/test_correlation.py +++ b/tests/unit/computations/test_correlation.py @@ -113,36 +113,23 @@ class TestCorrelation(TestCase): """Test for doing sample correlation gets the cor\ and p value and rho value using pearson correlation """ - primary_values = [2.3, 4.1, 5] - target_values = [3.4, 6.2, 4.1] + primary_values = [2.3, 4.1, 5, 4.2, None, None, 4, 1.2, 1.1] + target_values = [3.4, 6.2, 4, 1.1, 1.2, None, 8, 1.1, 2.1] - norm_vals.return_value = ([2.3, 4.1, 5, 4.2, 4, 1.2], - [3.4, 6.2, 4, 1.1, 8, 1.1], 6) - compute_corr.side_effect = [(0.7, 0.3), (-1.0, 0.9), (1, 0.21)] - pearson_results = compute_sample_r_correlation(trait_name="1412_at", - corr_method="pearson", - trait_vals=primary_values, - target_samples_vals=target_values) + norm_vals.return_value = iter( + [(2.3, 3.4), (4.1, 6.2), (5, 4), (4.2, 1.1), (4, 8), (1.2, 1.1), (1.1, 2.1)]) - spearman_results = compute_sample_r_correlation(trait_name="1412_at", - corr_method="spearman", - trait_vals=primary_values, - target_samples_vals=target_values) + + compute_corr.return_value = (0.8, 0.21) bicor_results = compute_sample_r_correlation(trait_name="1412_at", corr_method="bicor", trait_vals=primary_values, target_samples_vals=target_values) - self.assertEqual(bicor_results, ("1412_at", 1, 0.21, 6)) - self.assertEqual(pearson_results, ("1412_at", 0.7, 0.3, 6)) - self.assertEqual(spearman_results, ("1412_at", -1.0, 0.9, 6)) - self.assertIsInstance( - pearson_results, tuple, "message") - self.assertIsInstance( - spearman_results, tuple, "message") + self.assertEqual(bicor_results, ("1412_at", 0.8, 0.21, 7)) def test_filter_shared_sample_keys(self): """Function to tests shared key between two dicts""" |