Skip to content

Commit eee96c5

Browse files
committed
Changed the relative tolerance to be calculated to 2 significant figures instead of 1
1 parent 1fe2dcb commit eee96c5

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

app/evaluation_tests.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ def test_CHEM40002_1_5_instance_2024_25(self):
7979
result = evaluation_function(response, answer, params)
8080
assert result["is_correct"] is True
8181

82+
def test_physical_qualities_no_tolerance(self):
83+
params = {
84+
"atol": 0.0,
85+
"rtol": 0.0,
86+
"strict_syntax": False,
87+
"physical_quantity": True,
88+
"elementary_functions": True,
89+
}
90+
response = "0.6 Nm"
91+
answer = "0.5 Nm"
92+
result = evaluation_function(response, answer, params)
93+
assert result["is_correct"] is False
8294

8395
if __name__ == "__main__":
8496
pytest.main(['-xk not slow', '--tb=short', '--durations=10', os.path.abspath(__file__)])

app/utility/expression_utilities.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Default parameters for expression handling
22
# Any contexts that use this collection of utility functions
33
# must define values for theses parameters
4+
5+
DEFAULT_SIGNIFICANT_FIGURES = 2
6+
47
default_parameters = {
58
"complexNumbers": False,
69
"convention": "equal_precedence",
@@ -471,7 +474,7 @@ def compute_relative_tolerance_from_significant_decimals(string):
471474
index = min(separator_indices)
472475
significant_characters = string[0:index].replace(".", "")
473476
significant_characters = significant_characters.lstrip("-0")
474-
rtol = 5*10**(-len(significant_characters))
477+
rtol = 5*10**(-max(len(significant_characters), DEFAULT_SIGNIFICANT_FIGURES))
475478
return rtol
476479

477480

0 commit comments

Comments
 (0)