Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cms/grading/scoretypes/Sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ def compute_score(self, submission_result):
else:
public_testcases.append({"idx": idx})

score = round(score, self.score_precision)
public_score = round(public_score, self.score_precision)

return score, testcases, public_score, public_testcases, []

def get_public_outcome(self, outcome: float) -> str:
Expand Down
5 changes: 5 additions & 0 deletions cms/grading/scoretypes/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def __init__(
self.max_score, self.max_public_score, self.ranking_headers = (
self.max_scores()
)
# Sums of floats may accumulate errors (e.g. 0.1 + 0.2); round
# so that they compare equal to the (rounded) submission scores.
self.max_score = round(self.max_score, score_precision)
self.max_public_score = round(self.max_public_score, score_precision)
except Exception as e:
raise ValueError(
"Unable to instantiate score type (probably due to invalid "
Expand Down Expand Up @@ -639,6 +643,7 @@ def compute_score(self, submission_result):
# are rounded. However we are using floats not Decimals
# and this can cause errors. So we round again to be sure.
score = round(score, score_precision)
public_score = round(public_score, score_precision)

return score, subtasks, public_score, public_subtasks, ranking_details

Expand Down
Loading