Verify that cap > floor (#807)

This commit is contained in:
Ben Letham 2019-05-13 13:11:07 -07:00
parent 269133c133
commit 28cd55241f
2 changed files with 7 additions and 0 deletions

View file

@ -393,6 +393,9 @@ setup_dataframe <- function(m, df, initialize_scales = FALSE) {
if (!(exists('cap', where=df))) {
stop('Capacities must be supplied for logistic growth.')
}
if (any(df$cap <= df$floor)) {
stop('cap must be greater than floor (which defaults to 0).')
}
df <- df %>%
dplyr::mutate(cap_scaled = (cap - floor) / m$y.scale)
}

View file

@ -274,6 +274,10 @@ class Prophet(object):
"Capacities must be supplied for logistic growth in "
"column 'cap'"
)
if (df['cap'] <= df['floor']).any():
raise ValueError(
'cap must be greater than floor (which defaults to 0).'
)
df['cap_scaled'] = (df['cap'] - df['floor']) / self.y_scale
df['t'] = (df['ds'] - self.start) / self.t_scale