Fix plotting with 0 changepoints

This commit is contained in:
Maxim Grishin 2019-10-25 23:42:58 +03:00 committed by Ben Letham
parent 9425b89257
commit a6646670b9

View file

@ -441,7 +441,7 @@ def add_changepoints_to_plot(
artists.append(ax.plot(fcst['ds'], fcst['trend'], c=cp_color))
signif_changepoints = m.changepoints[
np.abs(np.nanmean(m.params['delta'], axis=0)) >= threshold
]
] if len(m.changepoints) > 0 else []
for cp in signif_changepoints:
artists.append(ax.axvline(x=cp, c=cp_color, ls=cp_linestyle))
return artists
@ -628,7 +628,7 @@ def plot_plotly(m, fcst, uncertainty=True, plot_cap=True, trend=False, changepoi
line=dict(color=trend_color, width=line_width),
))
# Add changepoints
if changepoints:
if changepoints and len(m.changepoints) > 0:
signif_changepoints = m.changepoints[
np.abs(np.nanmean(m.params['delta'], axis=0)) >= changepoints_threshold
]