From 703fad03660c8f4a5658bd4aecd3a18fad6ce10c Mon Sep 17 00:00:00 2001 From: Muriithi Frederick Muriuki Date: Thu, 22 Jul 2021 12:59:46 +0300 Subject: Check that distance from A to B is same as from B to A Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * gn3/computations/slink.py: check that the distance from child A to B is the same as distance from child B to A. If not, throw an exception. * tests/unit/computations/test_slink.py: * Change the name of the test to more closely correspond to the business logic being tested. * Update the data in a separate test such that it does not error out due to failing to fulfill the expectations of separate requirement. - pass tests - Rename test - Fix errors: distances same both directions --- tests/unit/computations/test_slink.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/unit/computations') diff --git a/tests/unit/computations/test_slink.py b/tests/unit/computations/test_slink.py index 1fb7bbb..207debf 100644 --- a/tests/unit/computations/test_slink.py +++ b/tests/unit/computations/test_slink.py @@ -44,7 +44,7 @@ class TestSlink(TestCase): with self.assertRaises(ValueError): nearest(lst, 1, 1) - def test_nearest_expects_exception_if_value_at_index_j_in_list_i_does_not_equals_value_at_index_i_in_list_j(self): + def test_nearest_expects_exception_if_distance_from_child_a_to_child_b_is_not_distance_from_child_b_to_child_a(self): for lst in [[[0,1],[2,0]], [[0,1,2],[1,0,3],[9,7,0]], [[0,1,2,3],[7,0,2,3],[2,3,0,1],[8,9,5,0]]]: @@ -56,12 +56,12 @@ class TestSlink(TestCase): # Based on: # https://github.com/genenetwork/genenetwork1/blob/master/web/webqtl/heatmap/slink.py#L87-L89 for lst in [[[0,1,2,3],[1,0,3,4],[2,3,0,5],[3,4,5,0]], - [[0,1,2,3],[-1,0,3,4],[2,3,0,5],[3,4,5,0]], - [[0,1,2,3],[1,0,3,4],[-2,3,0,5],[3,4,5,0]], - [[0,1,2,3],[1,0,3,4],[2,-3,0,5],[3,4,5,0]], - [[0,1,2,3],[1,0,3,4],[2,3,0,5],[-3,4,5,0]], - [[0,1,2,3],[1,0,3,4],[2,3,0,5],[3,-4,5,0]], - [[0,1,2,3],[1,0,3,4],[2,3,0,5],[3,4,-5,0]]]: + [[0,-1,2,3],[-1,0,3,4],[2,3,0,5],[3,4,5,0]], + [[0,1,-2,3],[1,0,3,4],[-2,3,0,5],[3,4,5,0]], + [[0,1,2,3],[1,0,-3,4],[2,-3,0,5],[3,4,5,0]], + [[0,1,2,-3],[1,0,3,4],[2,3,0,5],[-3,4,5,0]], + [[0,1,2,3],[1,0,3,-4],[2,3,0,5],[3,-4,5,0]], + [[0,1,2,3],[1,0,3,4],[2,3,0,-5],[3,4,-5,0]]]: with self.subTest(lst=lst): with self.assertRaises(ValueError, msg="Got an unexpected negative value!"): nearest(lst, 1, 1) -- cgit v1.2.3