Fixed math.abs not found

This commit is contained in:
Maximilian Giller 2024-05-06 23:02:37 +02:00
parent 42b593f7f3
commit dc22afdfc8

View file

@ -34,7 +34,7 @@ def get_clusters(data: list[float], min_delta: float) -> dict:
clusters = {} clusters = {}
for point in data: for point in data:
for known in clusters.keys(): for known in clusters.keys():
if math.abs(point - known) < min_delta: if math.fabs(point - known) < min_delta:
clusters[known].append(point) clusters[known].append(point)
continue continue
clusters[point] = [point] clusters[point] = [point]
@ -89,12 +89,10 @@ def check_for_change():
# Is triggered? # Is triggered?
delta = latest["total"] - local_history[-2]["total"] delta = latest["total"] - local_history[-2]["total"]
if math.abs(delta) < min_noticable_difference: if math.fabs(delta) < min_noticable_difference:
logging.info(f"Delta: {delta}")
return return
# Changed weight up or down? # Changed weight up or down?
logging.info(f"Delta: {delta}")
weight_increased = delta > 0 weight_increased = delta > 0
# Make sure there is a bed_weight # Make sure there is a bed_weight