aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gn3/computations/slink.py2
-rw-r--r--tests/unit/computations/test_slink.py7
2 files changed, 6 insertions, 3 deletions
diff --git a/gn3/computations/slink.py b/gn3/computations/slink.py
index 7d13d91..7b4016a 100644
--- a/gn3/computations/slink.py
+++ b/gn3/computations/slink.py
@@ -71,3 +71,5 @@ This description should be updated once the form/type of 'distance' identified."
raise_valueerror_on_negative_distances(lists)
#### END: Guard Functions ####
return None
+ if type(i) == int and type(j) == int: # From member i to member j
+ return lists[i][j]
diff --git a/tests/unit/computations/test_slink.py b/tests/unit/computations/test_slink.py
index 6be3f33..166eff9 100644
--- a/tests/unit/computations/test_slink.py
+++ b/tests/unit/computations/test_slink.py
@@ -65,9 +65,10 @@ class TestSlink(TestCase):
with self.assertRaises(ValueError, msg="Distances should be positive."):
nearest(lst, 1, 1)
- def test_nearest_with_expected(self):
- # Give this test a better name
- # The lists in this tests are taken from:
+ def test_nearest_returns_shortest_distance_given_coordinates_to_both_group_members(self):
+ # This test is named wrong - at least I think it is, from the expected results
+ # This tests distance when both `i`, and `j` are integers
+ # We still need to add tests for when (either one/both) (is/are) not (an) integer(s)
# https://github.com/genenetwork/genenetwork1/blob/master/web/webqtl/heatmap/slink.py#L39-L40
for lst, i, j, expected in [[[[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,0,0],