From 278f1a18b59b1cadd04c50a9af35b5aece4d722d Mon Sep 17 00:00:00 2001 From: Muriithi Frederick Muriuki Date: Fri, 23 Jul 2021 09:18:40 +0300 Subject: Add data examples for `slink`. Implement function. Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * gn3/computations/slink.py: Copy the function, mostly verbatim from genenetwork1. See: https://github.com/genenetwork/genenetwork1/blob/master/web/webqtl/heatmap/slink.py#L107-L138 * tests/unit/computations/test_slink.py: Add a test with some example data to test that the implementation gives the same results as that in genenetwork1 --- tests/unit/computations/test_slink.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/unit/computations') diff --git a/tests/unit/computations/test_slink.py b/tests/unit/computations/test_slink.py index da17ac3..5627767 100644 --- a/tests/unit/computations/test_slink.py +++ b/tests/unit/computations/test_slink.py @@ -207,3 +207,14 @@ class TestSlink(TestCase): for data in [1, "test", [], 2.945, nearest, [0]]: with self.subTest(data=data): self.assertEqual(slink(data), []) + + def test_slink_with_data(self): + for data, expected in [ + [[[0,9],[9,0]],[0,1,9]], + [[[0,9,3],[9,0,7],[3,7,0]],[(0,2,3),1,7]], + [[[0,9,3,6],[9,0,7,5],[3,7,0,9],[6,5,9,0]],[(0,2,3),(1,3,5),6]], + [[[0,9,3,6,11],[9,0,7,5,10],[3,7,0,9,2],[6,5,9,0,8], + [11,10,2,8,0]], + [(0,(2,4,2),3),(1,3,5),6]]]: + with self.subTest(data=data): + self.assertEqual(slink(data), expected) -- cgit v1.2.3