Repository navigation
Fix TypeError when the answer or response is an inequality - #297
Merged
Merged
Conversation
check_equality subtracted the two sides, which raises a TypeError for inequalities and booleans (e.g. a response of 8<9, or an answer of 5<1.43, which evaluates to False). Inequalities are not supported yet, so: - an inequality in the response is marked incorrect - an inequality in the answer raises a TaskConfigurationError Full inequality support is added by #276. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The evaluation logging from #294 showed 8
TypeErrorfailures in production in 24 hours (22–23 Oct), all ingenerate_feedbackatcheck_equality(app/context/symbolic.py).check_equalitysubtracts the two sides (lhs_expr-rhs_expr), which raises aTypeErrorwhen either side is an inequality or a boolean. There were two causes:drawmode where the recognised response was an inequality, e.g.8<9against an answer of8.5<1.43, which fails for every response.The user docs don't advertise inequalities as answers or responses (an EXPRESSION has no
=,<,>). Full support is added by #276, which is being ported onto the refactor. This PR is a hotfix that stops the crash onmainuntil then.Changes
app/context/symbolic.py: newis_inequality_or_booleanhelper (RelationalorBooleanAtom, but notEquality).check_equalityreturnsFalsewhen either side matches, in the same way as the existing guard for a loneEquality. It doesn't check forBoolean, because sympy'sSymbolis a subclass ofBoolean.app/evaluation.py:parse_reserved_expressionsraises aTaskConfigurationError(RESERVED_EXPRESSION_INEQUALITY_answer) when a task expression is an inequality or a boolean. The teacher then sees a configuration error, instead of every student being marked incorrect. The message only contains the label, so no user data is logged.app/tests/symbolic_evaluation_test.py: regression tests for both cases.Not changed:
check_order(criteria likeresponse > answer) has the same unguarded subtraction. It didn't appear in the logs.Checklist
app/docs.md) if user-facing behaviour changed. Not needed, since inequalities were never documented as supported.🤖 Generated with Claude Code