Skip to content

Feature/handwritting aliases#243

Open
m-messer wants to merge 4 commits into
mainfrom
feature/handwritting-aliases
Open

Feature/handwritting aliases#243
m-messer wants to merge 4 commits into
mainfrom
feature/handwritting-aliases

Conversation

@m-messer
Copy link
Copy Markdown
Member

@m-messer m-messer commented Dec 18, 2025

Problem:
Aliases were not supported if the student handrew the answer.
For example, if the answer is ab with the aliases ['aB', 'Ab', 'AB'] and the student wrote AB, it would not be marked as correct, as the LaTeX passing using the LaTeX from MathPiX would not return Sympy that evaluated the aliases.

Fix:
Parse the aliases in preview_utlities.py lines 182 to 199, including handling E as a symbol instead of Euler's numbers for when E is part of the input symbol. The except clause allows for aliases such as +-, which are not valid LaTeX.
Additionally, to support the substitutions, the Sympy function xreplace was replaced with subs as there were issues with canonical order and substituting symbols.

All other changes are tests to support validation of the functionality.

Database Testing Results (https://github.com/lambda-feedback/compareExpressions/actions/runs/25924874740):
8 errors out of 1000

  1. Grade mismatch: Eval: True, DB: False -- answer: -5 muA-- response: -5 μA
    • Mismatch due to greek letter fix.
  2. (x cosx - sinx) / (x^{2}) could not be parsed as a valid mathematical expression. Ensure that correct codes for input symbols are used, correct notation is used, that the expression is unambiguous and that all parentheses are closed.
  • Curly braces in answer
  1. (1/(2*a))*(( cos(( pi*x)/(2*a)))^2 + ( sin(( pi*x)/(a)))^2 + 2* cos(( pi*x)/(2a))* sin(( pi*x)/(a))* cos((DE*t)/(hbar))) could not be parsed as a valid mathematical expression. Ensure that correct codes for input symbols are used, correct notation is used, that the expression is unambiguous and that all parentheses are closed.
  • ??
  1. 3 − 14y + x could not be parsed as a valid mathematical expression. Ensure that correct codes for input symbols are used, correct notation is used, that the expression is unambiguous and that all parentheses are closed.
  • Unicode dash
  1. Grade mismatch: Eval: True, DB: False -- answer: e^(i*k*y*sin(theta))-- response: E^(iky sin(θ))
    • Mismatch due to greek letter fix
  2. −2 + 12x + y could not be parsed as a valid mathematical expression. Ensure that correct codes for input symbols are used, correct notation is used, that the expression is unambiguous and that all parentheses are closed.
  • Unicode dash
  1. 2( tan x) sec^(2) x could not be parsed as a valid mathematical expression. Ensure that correct codes for input symbols are used, correct notation is used, that the expression is unambiguous and that all parentheses are closed.
  • sec^(2)x not currently supported
  1. Grade mismatch: Eval: True, DB: False -- answer: pi/6-- response: π/6
    • Mismatch due to greek letter fix.

Copy link
Copy Markdown
Member

@peterbjohnson peterbjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

For failed DB tests, in future can you give a clearer response please, e.g. 'test failed due to known, unrelated issue' (and give the issue number if possible), or 'test failed due to updated code giving higher performance' (such as the Unicode upgrades; give PR number of possible. I know that can be extra work, so it's about balance. Hopefully exclusions via Firebase will help streamline this issue.

It was just hard to tell from your comments exactly whether the failure was ok. I concluded yes in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants