Fix a bug in simplify_expr() reading symbols with illegal characters #26531
+174
−0
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.
Fixes #26184
Description:
Issue author alfadir opened an issue about how using imported parameter names in parse_expr from sympy.parsing.sympy_parser contains symbols with special characters. This causes confusion in the parser where those imported symbols get mismatched and don't correctly align with the result. For example, "pro-duct" should match with "product". They provided a tok.py test script that they wrote which includes their proposed fix of using a dictionary to map the symbols, which only solved half of the problem, as seen in simplify_expr_new(). My changes implemented in simplify_expr_new_v2() add to their solution by including calls to the RegEx library to filter out integers (0-9) and characters
(+, -, .) from the input symbol so that the dictionary maps to that.
Release Notes