-
-
Notifications
You must be signed in to change notification settings - Fork 62
OutputForm #1570
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: master
Are you sure you want to change the base?
OutputForm #1570
Conversation
outputform and fullform following the WMA formatting steps
|
Any tests for this? |
I still have to add some specific tests. On the other hand, almost all the tests in doctests are reinforcing the final result. |
Actually, this brings up a broader concern, which is how do we know we're getting closer? How can we check compliance with Mathematica? (In looking at the last PR, I see that what we got using |
Co-authored-by: R. Bernstein <[email protected]>
Co-authored-by: R. Bernstein <[email protected]>
Is there a way to demonstrate this?
Doctests haven't changed, as far as I can tell. It would be nice to get some verifiable confirmation that this is moving in the right direction. |
mathics/format/outputform.py
Outdated
| ## TODO: handle complex numbers? | ||
| else: | ||
| elem_txt = expression_to_outputform_text(elem, evaluation, form, **kwargs) | ||
| if (compare_precedence(elem, 310) or -1) < 0: |
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.
What is the significance of 310? Perhaps it can be picked up from a table somewhere?
mathics/format/outputform.py
Outdated
| raise _WrongFormattedExpression | ||
|
|
||
| group = None | ||
| precedence = 670 |
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 before: what's the significance of 670?
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.
In the PR, I gather this is the operator precedence for a Box Group.
#1579 should start to cover this question. |
mathics/form/util.py
Outdated
| } | ||
|
|
||
|
|
||
| def bracket(expr_str: str) -> str: |
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.
Let's rename to square_brackets and the comment below.
I just looked this up. Bracket is the right term for [, and ], but in the comment below, I messed up and used the word "braces" (changed from "parenthesis"), which was wrong.
|
@mmatera There seem to be ongoing changes. Move this out of draft when you think it's ready for a final review. Thanks. |
mathics/form/inputform.py
Outdated
| # has a head that matches with a symbol associated to an infix | ||
| # operator, WMA builds its inputform without passing through | ||
| # its "Infix" form. | ||
| print("input infix", expr) |
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.
A couple of stray print statements here and below should be removed before this goes out of draft.
thanks! I was thinking of putting this as a draft, and I forgot it. Indeed, there are some other changes I want to add before this is ready to merge. |
Good to hear that there are more improvements in store! This is all good, and much-needed work. |
I have a private branch where I am testing the new OutputForm formatter, but by now it produces too many errors. As I consolidate the functions, I am putting them into this branch. |
mathics/form/util.py
Outdated
| def bracket(expr_str: str) -> str: | ||
| """Wrap `expr_str` with square braces""" | ||
| def square_bracket(expr_str: str) -> str: | ||
| """Wrap `expr_str` with square parenthesis""" |
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.
parenthesis -> brackets
…m. Handle TableForm
Now we have
PaneBoxandInterpretationBox, this PR implements a version ofOutputFormthat is more compatible with the one in WMA.