Avoid division by 0

Not quite sure how that could happen but it did.
This commit is contained in:
Peter J. Holzer 2022-12-30 21:31:50 +01:00 committed by Peter J. Holzer
parent f272b1ba95
commit 0595c19de9
1 changed files with 2 additions and 1 deletions

View File

@ -54,7 +54,8 @@ class LTS:
data = self.data data = self.data
n = len(data) n = len(data)
t_last = data[-1][0] t_last = data[-1][0]
dt = (t_last - data[-5][0]) / 4 dt = max((t_last - data[-5][0]) / 4, 1)
log.debug("dt = %s, n = %s", dt, n)
k = math.log((t_last - data[0][0]) / dt / n + 1) k = math.log((t_last - data[0][0]) / dt / n + 1)
for i in range(1, n): for i in range(1, n):
t_ideal = (math.exp(k * (n - i)/n) - 1) * (n * dt) t_ideal = (math.exp(k * (n - i)/n) - 1) * (n * dt)