diff options
author | Muriithi Frederick Muriuki | 2021-07-20 14:13:21 +0300 |
---|---|---|
committer | Muriithi Frederick Muriuki | 2021-07-20 14:13:21 +0300 |
commit | 5a8f4f3c85be4645c9a918bc25397170f4370341 (patch) | |
tree | cfe3dff7f99865aa16cf471a2db65fe159db7a67 /tests/unit | |
parent | 7d22039c2ae0aef6abc575008f11b95e555e3e9a (diff) | |
download | genenetwork3-5a8f4f3c85be4645c9a918bc25397170f4370341.tar.gz |
Add test for code to move over from GN1
Issue:
https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi
* .gitignore: ignore emacs temporary files
* gn3/computations/correlations2.py: add a dummy function
* tests/unit/computations/test_correlation.py: add unit tests for the function
As part of the move of the clustering and heatmap code over from GN1 to GN3,
this commit begins by providing some unit tests for the correlation function
used to ensure that the implementation that is built up here corresponds,
and produces the same results as the original.
This tests and the function might change in the new system, but for now, we
try and maintain bug-to-bug compatibility.
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/computations/test_correlation.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unit/computations/test_correlation.py b/tests/unit/computations/test_correlation.py index b1bc6ef..6153c8a 100644 --- a/tests/unit/computations/test_correlation.py +++ b/tests/unit/computations/test_correlation.py @@ -19,6 +19,7 @@ from gn3.computations.correlations import compute_all_lit_correlation from gn3.computations.correlations import compute_all_tissue_correlation from gn3.computations.correlations import map_shared_keys_to_values from gn3.computations.correlations import process_trait_symbol_dict +from gn3.computations.correlations2 import compute_correlation class QueryableMixin: @@ -464,3 +465,28 @@ class TestCorrelation(TestCase): trait_symbol_dict, tissue_values_dict) self.assertEqual(results, [expected_results]) + + def test_compute_correlation(self): + for dbdata,userdata,expected in [ + [[None,None,None,None,None,None,None,None,None,None], + [None,None,None,None,None,None,None,None,None,None], + (0.0, 0)], + [[None,None,None,None,None,None,None,None,None,0], + [None,None,None,None,None,None,None,None,None,None], + (0.0, 0)], + [[None,None,None,None,None,None,None,None,None,0], + [None,None,None,None,None,None,None,None,None,0], + (0.0, 1)], + [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0], + (0, 10)], + [[9.87,9.87,9.87,9.87,9.87,9.87,9.87,9.87,9.87,9.87], + [9.87,9.87,9.87,9.87,9.87,9.87,9.87,9.87,9.87,9.87], + (0.9999999999999998, 10)], + [[9.3,2.2,5.4,7.2,6.4,7.6,3.8,1.8,8.4,0.2], + [0.6,3.97,5.82,8.21,1.65,4.55,6.72,9.5,7.33,2.34], + (-0.12720361919462056, 10)], + [[0,1,2,3,4,5,6,7,8,9], + [None,None,None,None,2,None,None,3,None,None], + (0.0, 2)]]: + with self.subTest(dbdata=dbdata, userdata=userdata): + self.assertEqual(compute_correlation(dbdata,userdata), expected) |