Workaround for min and sec parsing problem #2961
Closed
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.
The expression parser
math.evaluate
currently has some confusion between the unitmin
(minutes) and the functionmin
(minimum). Similarly forsec
(seconds) and the functionsec
(secant). Presently, the units are mistakenly recognized as functions in the parser and results in errors. This issue was raised in #2095 and in later discussion within #2771It seems to me that function names should always be followed by left parenthesis "(" and the proper fix would be to have the parser look for that character to recognize any function. A fix like that should allow functions and units to coexist so that the user could even define new functions with names that match unit names without trouble. Currently, new functions like this will fail just like the built-in
sec
andmin
.I'm not familiar enough with the code to implement a change like describe above so, for a temporary workaround, I've added a regular expression to immediately rename any
min
andsec
units found in the parse expression.