Skip to content

Commit

Permalink
remove debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
MaHaWo committed Dec 17, 2024
1 parent 36681b3 commit 8bf453a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 24 deletions.
2 changes: 1 addition & 1 deletion mondey_backend/src/mondey_backend/routers/scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
13 changes: 1 addition & 12 deletions mondey_backend/src/mondey_backend/routers/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 0 additions & 11 deletions mondey_backend/tests/utils/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 8bf453a

Please sign in to comment.