mirror of https://github.com/Desuuuu/klipper.git
mcu: Prevent "math domain errors" in stats calculation
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
9335cc4804
commit
1b454c0943
|
@ -505,7 +505,8 @@ class MCU:
|
||||||
c = 1.0 / (count * self._mcu_freq)
|
c = 1.0 / (count * self._mcu_freq)
|
||||||
self._mcu_tick_avg = tick_sum * c
|
self._mcu_tick_avg = tick_sum * c
|
||||||
tick_sumsq = params['sumsq'] * self._stats_sumsq_base
|
tick_sumsq = params['sumsq'] * self._stats_sumsq_base
|
||||||
self._mcu_tick_stddev = c * math.sqrt(count*tick_sumsq - tick_sum**2)
|
diff = count*tick_sumsq - tick_sum**2
|
||||||
|
self._mcu_tick_stddev = c * math.sqrt(max(0., diff))
|
||||||
self._mcu_tick_awake = tick_sum / self._mcu_freq
|
self._mcu_tick_awake = tick_sum / self._mcu_freq
|
||||||
def _handle_shutdown(self, params):
|
def _handle_shutdown(self, params):
|
||||||
if self._is_shutdown:
|
if self._is_shutdown:
|
||||||
|
|
Loading…
Reference in New Issue