From 8bf453a34831a9d95ad07d694b7ccae22117dd20 Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Tue, 17 Dec 2024 21:18:33 +0100 Subject: [PATCH] remove debug output --- mondey_backend/src/mondey_backend/routers/scores.py | 2 +- .../src/mondey_backend/routers/statistics.py | 13 +------------ mondey_backend/tests/utils/test_statistics.py | 11 ----------- 3 files changed, 2 insertions(+), 24 deletions(-) diff --git a/mondey_backend/src/mondey_backend/routers/scores.py b/mondey_backend/src/mondey_backend/routers/scores.py index 7d620130..3971bcd8 100644 --- a/mondey_backend/src/mondey_backend/routers/scores.py +++ b/mondey_backend/src/mondey_backend/routers/scores.py @@ -75,7 +75,7 @@ def leq(val: float, lim: float) -> bool: else: lim_lower = stat.avg_score - 2 * stat.stddev_score lim_upper = stat.avg_score - stat.stddev_score - print("eval: ", lim_lower, lim_upper, stat.avg_score, score) + if leq(score, lim_lower): return TrafficLight.red.value elif score > lim_lower and leq(score, lim_upper): diff --git a/mondey_backend/src/mondey_backend/routers/statistics.py b/mondey_backend/src/mondey_backend/routers/statistics.py index 9aacd7ad..5a3d5b58 100644 --- a/mondey_backend/src/mondey_backend/routers/statistics.py +++ b/mondey_backend/src/mondey_backend/routers/statistics.py @@ -164,14 +164,9 @@ def _get_statistics_by_age( for answer in answers: age = child_ages[answer.answer_session_id] # type: ignore - print(" answer: ", answer) - print(" age: ", age) new_count, new_avg, new_m2 = _add_sample( count[age], avg[age], m2[age], answer.answer + 1 ) - print(" new_count: ", new_count) - print(" new_avg: ", new_avg) - print(" new_m2: ", new_m2) count[age] = new_count avg[age] = new_avg m2[age] = new_m2 @@ -311,20 +306,16 @@ def calculate_milestonegroup_statistics_by_age( # get the newest statistics for the milestonegroup last_statistics = session.get(MilestoneGroupAgeScoreCollection, milestonegroup_id) - print(" last_statistics", last_statistics) - for i, s in enumerate(last_statistics.scores): - print(" score: ", i, s.count, s.avg_score, s.stddev_score) child_ages = _get_answer_session_child_ages_in_months(session) expiration_date = datetime.datetime.now() - relativedelta(days=session_expired_days) - print(" expiration_date: ", expiration_date) + count = None avg_scores = None stddev_scores = None # we have 2 kinds of querys that need to be executed depending on the existence of a statistics object if last_statistics is None: - print(" no existing statistics") # no statistics exists yet -> all answers from expired sessions are relevant answer_query = ( select(MilestoneAnswer) @@ -339,7 +330,6 @@ def calculate_milestonegroup_statistics_by_age( ) ) else: - print(" existing statistics") # initialize avg and stddev scores with the last known statistics count = np.array( [score.count for score in last_statistics.scores], dtype=np.int32 @@ -369,7 +359,6 @@ def calculate_milestonegroup_statistics_by_age( ) answers = session.exec(answer_query).all() - print(" answers: ", answers) if len(answers) == 0: # return last statistics if no new answers are available, because that is the best we can do then. diff --git a/mondey_backend/tests/utils/test_statistics.py b/mondey_backend/tests/utils/test_statistics.py index 09a0a578..a0ca079e 100644 --- a/mondey_backend/tests/utils/test_statistics.py +++ b/mondey_backend/tests/utils/test_statistics.py @@ -89,7 +89,6 @@ def test_online_statistics_computation_too_little_data(): def test_get_score_statistics_by_age(session): answers = session.exec(select(MilestoneAnswer)).all() - print(answers) # which answers we choose here is arbitrary for testing, we just need to make sure it's fixed and not empty child_ages = { 1: 5, @@ -213,12 +212,6 @@ def test_calculate_milestone_statistics_by_age(statistics_session): # we have nothing new for everything else for age in range(0, len(mscore.scores)): - print( - age, - mscore.scores[age].count, - mscore.scores[age].avg_score, - mscore.scores[age].stddev_score, - ) if age != 8: assert mscore.scores[age].count == 12 avg = 0 if age < 5 else min(1 * age - 5, 3) @@ -242,10 +235,6 @@ def test_calculate_milestonegroup_statistics(statistics_session): milestone_group.id, ) - print("milestonegroup id ", score.milestone_group_id) - for i, s in enumerate(score.scores): - print(i, s.count, s.avg_score, s.stddev_score) - assert score.milestone_group_id == 1 # no change for these ages assert np.isclose(score.scores[5].avg_score, 1.2)