From b08bf586d653d2243d8bc7a321227f287ce99a74 Mon Sep 17 00:00:00 2001 From: Muriithi Frederick Muriuki Date: Fri, 23 Jul 2021 05:34:59 +0300 Subject: New function (`slink`): return [] on exception Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * gn3/computations/slink.py: Add minimum code to pass new test * tests/unit/computations/test_slink.py: new test Add test to ensure that the new `slink` function return an empty list in case and exception is raised. Add the new `slink` function with minimum amount of code needed to pass the test. --- gn3/computations/slink.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gn3/computations') diff --git a/gn3/computations/slink.py b/gn3/computations/slink.py index c29ddb0..103a853 100644 --- a/gn3/computations/slink.py +++ b/gn3/computations/slink.py @@ -6,6 +6,7 @@ FUNCTIONS: slink: TODO: Describe what the function does... """ +import logging from functools import partial class LengthError(BaseException): @@ -116,3 +117,14 @@ def nearest(lists, i, j): return min(ns) else: raise ValueError("member values (i or j) should be lists/tuples of integers or integers") + +def slink(lists): + """ + """ + try: + nearest(lists, 1, 2) + except Exception as e: + # TODO: Look into making the logging log output to the system's + # configured logger(s) + logging.warning("Exception: {}, {}".format(type(e), e)) + return [] -- cgit v1.2.3