From bc1b310503d63555ffe9d2da0a881f11b666fa3b Mon Sep 17 00:00:00 2001 From: Alexander Kabui Date: Mon, 29 Nov 2021 00:27:19 +0300 Subject: refactor sample r unittests --- tests/unit/computations/test_correlation.py | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) (limited to 'tests/unit') 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""" -- cgit v1.2.3