Don't try to render timeseries which are too short

This commit is contained in:
Peter J. Holzer 2022-12-30 21:32:48 +01:00 committed by Peter J. Holzer
parent 0595c19de9
commit d6bdaa4128
1 changed files with 2 additions and 0 deletions

View File

@ -152,6 +152,8 @@ class TimeSeries(Widget):
data = self.lts.data data = self.lts.data
n = len(data) n = len(data)
t_last = data[-1][0] t_last = data[-1][0]
if len(data) < 5:
return "(not enough data)"
dt = (t_last - data[-5][0]) / 4 dt = (t_last - data[-5][0]) / 4
k = math.log((t_last - data[0][0]) / dt / n + 1) k = math.log((t_last - data[0][0]) / dt / n + 1)