diff options
-rw-r--r-- | gn3/computations/slink.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gn3/computations/slink.py b/gn3/computations/slink.py index d6f6028..704a0f4 100644 --- a/gn3/computations/slink.py +++ b/gn3/computations/slink.py @@ -12,6 +12,14 @@ def raise_valueerror_if_data_is_not_lists_or_tuples(lists): if (not is_list_or_tuple(lists)) or (not all(map(is_list_or_tuple, lists))): raise ValueError("Expected list or tuple") +def raise_valueerror_if_lists_empty(lists): + """Check that the list and its direct children are not empty.""" + def empty(lst): + return len(lst) == 0 + if (empty(lists)) or not all(map(lambda x: not empty(x), lists)): + raise ValueError("List/Tuple should NOT be empty!") + def nearest(lists, i, j): raise_valueerror_if_data_is_not_lists_or_tuples(lists) + raise_valueerror_if_lists_empty(lists) return None |