Skip to content

Commit 5fb54a1

Browse files
Fixed bug when response is an equality with both sides identical
1 parent d712195 commit 5fb54a1

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

app/context/symbolic.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,12 @@ def equality_equivalence(unused_input):
316316

317317
# TODO: Remove when criteria for checking proportionality is implemented
318318
if isinstance(res, Equality) and isinstance(ans, Equality):
319-
symbols_in_equality_ratio = ((res.args[0]-res.args[1])/(ans.args[0]-ans.args[1])).simplify().free_symbols
319+
if (res.args[0]-res.args[1]).simplify() == 0:
320+
symbols_in_equality_ratio = (ans.args[0]-ans.args[1]).simplify().free_symbols
321+
elif (ans.args[0]-ans.args[1]).simplify() == 0:
322+
symbols_in_equality_ratio = (res.args[0]-res.args[1]).simplify().free_symbols
323+
else:
324+
symbols_in_equality_ratio = ((res.args[0]-res.args[1])/(ans.args[0]-ans.args[1])).simplify().free_symbols
320325
result = {str(s) for s in symbols_in_equality_ratio}.issubset(parameters_dict["parsing_parameters"]["constants"])
321326
if result is True:
322327
return {

app/tests/symbolic_evaluation_tests.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,5 +1970,24 @@ def test_input_symbols_takes_priority_when_containing_elementary_function_names_
19701970
result = evaluation_function(response, answer, params)
19711971
assert result["is_correct"] is True
19721972

1973+
def test_equality_with_both_sides_equal_in_response(self):
1974+
response = "(1/3)^(1/4)= (1/3)^(1/4)"
1975+
answer = "Vbar=(1/3)^(1/4)"
1976+
params = {
1977+
'atol': 0,
1978+
'rtol': 0,
1979+
'strict_syntax': False,
1980+
'elementary_functions': True,
1981+
'symbols': {
1982+
'LtDmax': {'aliases': [''], 'latex': '$(L/D)_{max}$'},
1983+
'etap': {'aliases': [''], 'latex': '$\\eta_p$'},
1984+
'sigma': {'aliases': [''], 'latex': '$\\sigma$'},
1985+
'Vbar': {'aliases': [''], 'latex': '$\\overline{V}$'},
1986+
'Pbar': {'aliases': [''], 'latex': '$\\overline{P}$'},
1987+
},
1988+
}
1989+
result = evaluation_function(response, answer, params)
1990+
assert result["is_correct"] is False
1991+
19731992
if __name__ == "__main__":
19741993
pytest.main(['-xk not slow', "--tb=line", '--durations=10', os.path.abspath(__file__)])

0 commit comments

Comments
 (0)