File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 5151# third party
5252import mysql .connector
5353import numpy as np
54+ from warnings import warn
5455
5556# first party
5657import delphi .operations .secrets as secrets
5758from delphi .utils .epiweek import delta_epiweeks
5859from delphi .utils .geo .locations import Locations
5960
6061
62+ UNDERDETERMINED_MSG = "system is underdetermined"
63+
6164class Database :
6265 """Database wrapper and abstraction layer."""
6366
@@ -240,7 +243,7 @@ def get_fusion_parameters(known_locations):
240243 H = graph [is_known , :]
241244 W = graph [is_unknown , :]
242245 if np .linalg .matrix_rank (H ) != len (atoms ):
243- raise StatespaceException ("system is underdetermined" )
246+ raise StatespaceException (UNDERDETERMINED_MSG )
244247
245248 HtH = np .dot (H .T , H )
246249 HtH_inv = np .linalg .inv (HtH )
@@ -293,7 +296,15 @@ def impute_missing_values(database, test_mode=False):
293296 known_values ["pr" ] = (0 , 0 , 0 )
294297
295298 # get the imputation matrix and lists of known and unknown locations
296- F , known , unknown = get_fusion_parameters (known_values .keys ())
299+ try :
300+ F , known , unknown = get_fusion_parameters (known_values .keys ())
301+ except StatespaceException as e :
302+ message = str (e )
303+ if message == UNDERDETERMINED_MSG :
304+ warn (message )
305+ else :
306+ print (message )
307+ continue
297308
298309 # finally, impute the missing values
299310 z = np .array ([known_values [k ] for k in known ])
You can’t perform that action at this time.
0 commit comments