aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gn3/computations/slink.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/gn3/computations/slink.py b/gn3/computations/slink.py
index 0c74789..7ee9b5e 100644
--- a/gn3/computations/slink.py
+++ b/gn3/computations/slink.py
@@ -64,10 +64,13 @@ raise an exception."""
def zero_or_positive(val):
return val >= 0;
# flatten lists
- flattened = [distance for child in lists for distance in child]
+ flattened = __flatten_list_of_lists(lists)
if not all(map(zero_or_positive, flattened)):
raise ValueError("Distances should be positive.")
+def __flatten_list_of_lists(parent):
+ return [item for child in parent for item in child]
+
def nearest(lists, i, j):
"""
Computes shortest distance between member(s) in `i` and member(s) in `j`.