From cd99d8be751f255063f512396e29edaf465d9154 Mon Sep 17 00:00:00 2001 From: David Kane Date: Sun, 12 Apr 2020 13:59:28 +0100 Subject: [PATCH] error catching on latest_income --- data_import/import_data.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/data_import/import_data.py b/data_import/import_data.py index 094e469e..12134690 100644 --- a/data_import/import_data.py +++ b/data_import/import_data.py @@ -718,9 +718,14 @@ def clean_char(char): if n: w = n.split() words.update([" ".join(w[r:]) for r in range(len(w))]) + + try: + weight = max(1, math.ceil(math.log1p((char.get("latest_income", 0) or 0)))) + except ValueError: + weight = 1 char["complete_names"] = { "input": list(words), - "weight": max(1, math.ceil(math.log1p((char.get("latest_income", 0) or 0)))) + "weight": weight, } char["last_modified"] = datetime.datetime.now()