Skip to content

Commit a2dd059

Browse files
Merge pull request #137 from lambda-feedback/tr112-atol-rtol-zero-behaviour
Modified condition for numerical comparison to check if atol or rtol …
2 parents b4baab6 + c08a348 commit a2dd059

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

app/symbolic_comparison_evaluation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def symbolic_comparison(response, answer, params, eval_response) -> dict:
271271
error_below_rtol = None
272272

273273
if eval_response.is_correct is False:
274-
if params.get("numerical", False) or params.get("rtol", False) or params.get("atol", False):
274+
if params.get("numerical", False) or float(params.get("rtol", 0)) > 0 or float(params.get("atol", 0)) > 0:
275275
# REMARK: 'pi' should be a reserved symbol but it is sometimes not treated as one, possibly because of input symbols.
276276
# The two lines below this comments fixes the issue but a more robust solution should be found for cases where there
277277
# are other reserved symbols.

app/symbolic_comparison_evaluation_tests.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,54 @@ def test_empty_input_symbols_codes_and_alternatives(self):
552552
@pytest.mark.parametrize(
553553
"description,response,answer,tolerance,tags,outcome",
554554
[
555+
(
556+
"Correct response, symbolic comparison set with atol=0",
557+
"sqrt(3)+5",
558+
"sqrt(3)+5",
559+
{"atol": 0},
560+
[],
561+
True
562+
),
563+
(
564+
"Incorrect response, symbolic comparison set with atol=0",
565+
"sqrt(3)+5",
566+
"6.73",
567+
{"atol": 0},
568+
[],
569+
False
570+
),
571+
(
572+
"Correct response, symbolic comparison set with rtol=0",
573+
"sqrt(3)+5",
574+
"sqrt(3)+5",
575+
{"rtol": 0},
576+
[],
577+
True
578+
),
579+
(
580+
"Incorrect response, symbolic comparison set with rtol=0",
581+
"sqrt(3)+5",
582+
"6.73",
583+
{"rtol": 0},
584+
[],
585+
False
586+
),
587+
(
588+
"Correct response, symbolic comparison set with atol=0 and rtol=0",
589+
"sqrt(3)+5",
590+
"sqrt(3)+5",
591+
{"rtol": 0, "atol": 0},
592+
[],
593+
True
594+
),
595+
(
596+
"Incorrect response, symbolic comparison set with atol=0 and rtol=0",
597+
"sqrt(3)+5",
598+
"6.73",
599+
{"rtol": 0, "atol": 0},
600+
[],
601+
False
602+
),
555603
(
556604
"Correct response, tolerance specified with atol",
557605
"6.73",

0 commit comments

Comments
 (0)