Skip to content

Conversation

@mmatera
Copy link
Contributor

@mmatera mmatera commented Dec 28, 2025

Now we have PaneBox and InterpretationBox, this PR implements a version of OutputForm that is more compatible with the one in WMA.

@rocky
Copy link
Member

rocky commented Dec 28, 2025

Any tests for this?

@mmatera
Copy link
Contributor Author

mmatera commented Dec 28, 2025

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.

@rocky
Copy link
Member

rocky commented Dec 28, 2025

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 //TableForm//MathML was diffferent that what I saw in wolframscript. I didn't ask about it then, because I guess it might be a one-off situation.)

@rocky
Copy link
Member

rocky commented Dec 28, 2025

this PR implements a version of OutputForm that is more compatible with the one in WMA.

Is there a way to demonstrate this?

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.

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.

## TODO: handle complex numbers?
else:
elem_txt = expression_to_outputform_text(elem, evaluation, form, **kwargs)
if (compare_precedence(elem, 310) or -1) < 0:
Copy link
Member

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?

raise _WrongFormattedExpression

group = None
precedence = 670
Copy link
Member

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?

Copy link
Member

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.

@mmatera
Copy link
Contributor Author

mmatera commented Dec 30, 2025

Any tests for this?

#1579 should start to cover this question.

}


def bracket(expr_str: str) -> str:
Copy link
Member

@rocky rocky Jan 11, 2026

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.

@rocky rocky marked this pull request as draft January 11, 2026 13:21
@rocky
Copy link
Member

rocky commented Jan 11, 2026

@mmatera There seem to be ongoing changes. Move this out of draft when you think it's ready for a final review. Thanks.

# 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)
Copy link
Member

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.

@mmatera
Copy link
Contributor Author

mmatera commented Jan 11, 2026

@mmatera There seem to be ongoing changes. Move this out of draft when you think it's ready for a final review. Thanks.

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.

@rocky
Copy link
Member

rocky commented Jan 11, 2026

@mmatera There seem to be ongoing changes. Move this out of draft when you think it's ready for a final review. Thanks.

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.

@mmatera
Copy link
Contributor Author

mmatera commented Jan 11, 2026

@mmatera There seem to be ongoing changes. Move this out of draft when you think it's ready for a final review. Thanks.

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.

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"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parenthesis -> brackets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants