in orbit/template/ktr.py [0:0]
def _filter_coef_prior(self, df):
if self._coef_prior_list and len(self._regressor_col) > 0:
# iterate over a copy due to the removal operation
for test_dict in self._coef_prior_list[:]:
prior_regressor_col = test_dict[
KTRTimePointPriorKeys.PRIOR_REGRESSOR_COL.value
]
m = test_dict[KTRTimePointPriorKeys.PRIOR_MEAN.value]
sd = test_dict[KTRTimePointPriorKeys.PRIOR_SD.value]
end_tp_idx = min(
test_dict[KTRTimePointPriorKeys.PRIOR_END_TP_IDX.value], df.shape[0]
)
start_tp_idx = min(
test_dict[KTRTimePointPriorKeys.PRIOR_START_TP_IDX.value],
df.shape[0],
)
if start_tp_idx < end_tp_idx:
expected_shape = (
end_tp_idx - start_tp_idx,
len(prior_regressor_col),
)
test_dict.update(
{KTRTimePointPriorKeys.PRIOR_END_TP_IDX.value: end_tp_idx}
)
test_dict.update(
{KTRTimePointPriorKeys.PRIOR_START_TP_IDX.value: start_tp_idx}
)
# mean/sd expanding
test_dict.update(
{
KTRTimePointPriorKeys.PRIOR_MEAN.value: np.full(
expected_shape, m
)
}
)
test_dict.update(
{
KTRTimePointPriorKeys.PRIOR_SD.value: np.full(
expected_shape, sd
)
}
)
else:
# removing invalid prior
self._coef_prior_list.remove(test_dict)