Skip to content

Fix/mech5003#245

Merged
m-messer merged 5 commits intomainfrom
fix/mech5003
Jan 15, 2026
Merged

Fix/mech5003#245
m-messer merged 5 commits intomainfrom
fix/mech5003

Conversation

@m-messer
Copy link
Copy Markdown
Member

Problem:
compareExpressions unable to correctly parse as as a*s as Python has an in-built 'as' function and these are parsed first before mathematical symbols. The same issue that we have with 'lambda'.

Fix: Following the same fix for lambda, added a substitution which substitutes as for a*s if as is not in the input_symbol list. If it is, then Sympy will treat as as a Symbol. Added tests to preview and evaluate to validate that it works as intended.

Comment thread app/evaluation_tests.py Outdated
# we need to make sure it is not substituted back in
substitutions = [(original, subs.replace("lambda", "lamda")) for (original, subs) in substitutions]

# Since 'as' is a reserved keyword in python, we add a subsitution of 'as' to 'a*s' if 'as' is not a defined symbol
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If more reserved words emerge:

  • Could we anticipate them? Can we find a list of Python reserved words?
  • Would it make sense to group the treatment rather than adding them one at a time?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will add this to the backlog to refactor

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. I've made comments that I suggest you act on. But I'm approving so that you don't need further review.

@m-messer m-messer merged commit 6210029 into main Jan 15, 2026
@m-messer m-messer deleted the fix/mech5003 branch January 15, 2026 12:46
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