-
Notifications
You must be signed in to change notification settings - Fork 0
Bug/fix inappropriate symbol and ! for factorial #227
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
base: main
Are you sure you want to change the base?
Conversation
…t least according to SymPy and correctly parse.
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.
Please can we discuss this (with Phil). I wonder if it's better to build a transformer at the token level and register it with the other transformers, rather than running a custom loop on the string.
Possible issues currently:
- triple factorial (!!!) and so on up to n
- precedence e.g.: 2^3!
- functions e.g.
sin(1)!!
becomessinfactorial2((1))
which I think at best would givesin*factorial2((1))
which is incorrect?
We should be using the tokeniser that we have, which already manages parentheses and precedence. That should make a more robust and extensible post-fix operator, similar to implicit multiplicaiton etc.
Thank you for the feedback. I'll add it to the list to discuss in our next meeting, which I will book soon. This was one failing test, which I thought would be an easy fix! The existing parsing of elementary functions works by replacing key terms with defaults. For example, This might be something we do in Wolfram instead of Python?
Overall, I think you are right that this is not the correct solution. Looking through Karl's code this morning, he had a warning message for With a quick test on the Wolfram evaluation function, ! is supported natively. My recommendation would be that, as we develop Wolfram, we include the factorial function into those evaluation functions, remove this work, and delete the failing test. |
Thanks for revisiting this. I agree to splitting the infinity test and the factorial part. For the factorial we don't necessarily need to give up completely. Did you try using the transformer that ships with SymPy? I've attached a MWE. |
Removed -∞ == -inf test when strict_syntax is enabled. Test was expecting a parsing failure, but Sympy parses ∞.
Additionally, implemented
!
and!!
to be parsed to sympy when usingelementary_functions