-
Notifications
You must be signed in to change notification settings - Fork 0
Bug/gh 223 implicit multi custom symbol #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… symbols are not currently working, and that in-build symbols (theta) do.
…d implicit multiplication
peterbjohnson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to my other review, we need to review whether this approach is appropriate, or whether we should be integrating more with the existing parsing.
Regarding adding a parameter that only works with another parameter, that may be problematic. E.g. (for illustration)implicit_multiplication_higher_precedence_A and implicit_multiplication_higher_precedence_B where e.g. A is normalise and B is nonnormalised - or whatever we agree on.
I'm also not clear what 'normalise' means here. It has many meanings generally and in this context it's not obvious to me.
|
I took a look at the transformers, including the depths of Sympy and its tokeniser. Sympy doesn't handle the case where If we are happy to go ahead with this, I will rename them |
|
I don't know if it's needed in other cases, I was just following your comment that it's only needed with implicit multiplication. I think implicit multiplication works ok with Easiest will be for me to ask you when I have a chance. |
# Conflicts: # app/utility/expression_utilities.py # custom_comparison_with_criteria_order_1.md
…icit multiplication
app/tests/multi_character_test.py
Outdated
| "f": {"aliases": ["f"]}, | ||
| "g": {"aliases": ["g"]}, | ||
| } | ||
| # a/bc + d/ef should be a/(b*c) + d/(e*f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is redundant (and is inconsistent because it still contains an 'e'.
app/tests/multi_character_test.py
Outdated
| "d": {"aliases": ["d"]}, | ||
| "f": {"aliases": ["f"]}, | ||
| } | ||
| # a/bcde should be a/(b*c*d*e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of these comments are redundant
peterbjohnson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good.
I've made a couple of inline comments that need addressing.
Also for the class that tests 'implicit' multiplication, I can see from the code that it all uses the convention of higher precedence for implicit multiplication. The naming of all of the functions just refers to 'implicit' though, which is not a complete description and can be confusing. Maybe you already thought about this and decided that it's fine. But if you haven't thought about it, consider making it clear/explicit that those tests are for the higher precedence convention. E.g. a/bcd = a/(bc.d) is only true for that convention, it's not true otherwise.
…only for implicit_higher_precedence
UPDATED
Problem:
Support for custom multi-character symbols, such as
bc, is not correctly supported by compareExpressions when using implicit multiplication.For example:$a/(bc*d)$
Answer:
Symbols:
a,bc,dValid solutions that are marked as incorrect
$a/(bcd)$
$a/bcd$
Identified bug:
The parser was unable to identify the multicharacter symbols in the expression.
For example, the symbol
bcin the answerbc*dand the submissionbcdwill be parsed asb * c * d, as the parser works on identifying symbols through space characters. Therefore, it could not find the symbolbc.Solution:
utlitiy/expression_utlities.pyline 742 - ensure that a space is on either side of any symbols that are parsed as parameters.Sympy will then strip any spaces when parsing the symbols.
Further changes:
docs/user.md- Removed reference to the workaround which is no longer neededevaluation_tests.py- Added tests for validating if multicharacters and implicit multiplication workspreview_tests.py- Added a multicharacter implicit multiplication test for previewtests/multi_character_tests.py- Added a further in-depth test suitetests/symbolic_evaluation_tests.py- Unrelated fix for failing tests for reserved special functions Lambda and chi, which were added in PR Feature/unicode support #237__init__.py- Madeutilitya Python packageutlity/expression_utilities.py- Mostly formatting changes other than the fix mentioned above