Skip to content

Commit 7b5a4ea

Browse files
committed
include Sunday and warn if big but finite
1 parent c2890b3 commit 7b5a4ea

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

_delphi_utils_python/delphi_utils/weekday.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,15 @@ def get_params(data, denominator_col, numerator_cols, date_col, scales, logger):
4141
logger.error("Unable to calculate weekday correction")
4242
else:
4343
params[i,:] = result
44-
if np.exp(-params).max() == np.inf:
44+
# the values multiplied by in calc_adjustment
45+
# Sunday, the last day here, is a sum of the other days
46+
effective_multipliers = np.exp(np.concatenate([-params[:,:6], params[:,:6].sum(axis=0, keepdims = True)]))
47+
48+
if effective_multipliers.max() == np.inf or effective_multipliers.min() == -np.inf:
4549
logger.warning("largest weekday correction is infinite. Defaulting to no correction")
4650
params = np.zeros((nums.shape[1], X.shape[1]))
51+
else if effective_multipliers.max() > 1000:
52+
logger.warning("largest weekday correction is over a factor of 1000. This is probably an error, but may be associated with a zero value.")
4753
return params
4854

4955
@staticmethod

0 commit comments

Comments
 (0)