Skip to content

Conversation

@mmatera
Copy link
Contributor

@mmatera mmatera commented Dec 30, 2025

This PR activates some pytests I wrote a while ago, -and adds more- to start quantifying the progress in the MakeBoxes refactor. Ideally, test/builtin/test_makeboxes.py should start to pass more tests as we make progress in driving the behavior to a one compatible with WMA.

@mmatera mmatera mentioned this pull request Dec 30, 2025
(
r"MakeBoxes[3.142`3]",
r"3.142`3",
"StandadForm with Prec real shows all the stored digits, and prec",
Copy link
Member

@rocky rocky Dec 30, 2025

Choose a reason for hiding this comment

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

Suggested change
"StandadForm with Prec real shows all the stored digits, and prec",
"StandardForm with real precision shows all the stored digits, and precision",

[
(r"MakeBoxes[1.4]", r"1.4`", None),
(r"MakeBoxes[1.4`]", r"1.4`", None),
(r"MakeBoxes[1.4`]", r"1.4`", "StandardForm always shows a prec mark."),
Copy link
Member

@rocky rocky Dec 30, 2025

Choose a reason for hiding this comment

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

Suggested change
(r"MakeBoxes[1.4`]", r"1.4`", "StandardForm always shows a prec mark."),
(r"MakeBoxes[1.4`]", r"1.4`", "StandardForm always shows a precision mark."),

(
r"MakeBoxes[OutputForm[3.142`3]]",
r'InterpretationBox[PaneBox["3.14"], 3.14, Editable -> False]',
"OutputForm trims digits up to prec.",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"OutputForm trims digits up to prec.",
"OutputForm trims digits up to precision.",

Copy link
Member

Choose a reason for hiding this comment

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

The abbreviation "prec" can confuse me to mean precedence or preceding. While I see this as a parameter name in some WMA documentation, outside of that I am not seeing this in common use as a shorthand for precision.

("MakeBoxes[x]", '"x"', "StandardForm"),
(
"MakeBoxes[InputForm[x]]",
'InterpretationBox[StyleBox["x", ShowStringCharacters -> True, NumberMarks -> True], InputForm[x], Editable -> True, AutoDelete -> True]',
Copy link
Member

Choose a reason for hiding this comment

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

WMA has x, instead of InputForm[x] and there are no quotes around "x" in StyleBox["x"]. What gives?

),
(
"MakeBoxes[OutputForm[x]]",
'InterpretationBox[PaneBox[""x""], OutputForm[x], Editable -> False]',
Copy link
Member

@rocky rocky Dec 31, 2025

Choose a reason for hiding this comment

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

Also I see a duplicate set of quotes. I am wondering about the merits of having exhaustive tests that are wrong, versus having limited tests that are right with tests that are skipped that need to be worked on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am trying to get useful references from WMA. This is exactly what I get when I evaluate MakeBoxes[OutputForm[x]]//InputForm in the WMA CLI.

Copy link
Member

@rocky rocky Dec 31, 2025

Choose a reason for hiding this comment

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

What I see is:

InterpretationBox[PaneBox["\"x\"", BaselinePosition -> Baseline], x,  Editable -> False]

Note the extra backslashes. This is slightly different.

r"MakeBoxes[3.142`3]",
r"3.142`3",
"StandardForm with PrecisionReal shows all the stored digits, and precision",
"StandadForm with PrecisionReal shows all the stored digits, and precision.",
Copy link
Member

Choose a reason for hiding this comment

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

Seems like a regression here.

@mmatera
Copy link
Contributor Author

mmatera commented Jan 2, 2026

With this change, we can do something like this:

./convert_yaml2json.py makeboxes_tests.yaml &  wolframscript -f makeboxes_tests.m 

and compare with

./convert_yaml2json.py makeboxes_tests.yaml &  mathics -f makeboxes_tests.m 

This is the output of the first command (using wolframscript):

Read json
Found 4 expressions to test.

Basic Forms
===========

  Arithmetic
  ==========
    FullForm   [OK]
    InputForm   [OK]
    OutputForm   [OK]
    StandardForm   [OK]
    TeXForm   [OK]

  Expression
  ==========
    Format   [OK]
    TraditionalForm   [OK]
    FullForm   [OK]
    InputForm   [OK]
    OutputForm   [OK]
    StandardForm   [OK]
    TeXForm   [OK]

  Integer_negative
  ================
    FullForm   [OK]
    InputForm   [OK]
    OutputForm   [OK]
    StandardForm   [OK]
    TeXForm   [OK]

  Integer_positive
  ================
    FullForm   [OK]
    InputForm   [OK]
    OutputForm   [OK]
    StandardForm   [OK]
    TeXForm   [OK]

  PrecisionReal
  =============
    FullForm   [OK]
    InputForm   [OK]
    OutputForm   [OK]
    StandardForm   [OK]
    TeXForm   [OK]

  Symbol
  ======
    FullForm   [OK]
    InputForm   [OK]
    OutputForm   [OK]
    StandardForm   [OK]
    TeXForm   [OK]

Numbers
=======

  MachineReal, positive
  =====================
    StandardForm   [OK]
    OutputForm   [OK]

  MachineReal, negative
  =====================
    StandardForm   [OK]
    OutputForm   [OK]

  MachineReal, Large
  ==================
    StandardForm   [OK]

  MachineReal, Very Large
  =======================
    StandardForm   [OK]

  PrecisionReal, Few Digits
  =========================
    StandardForm   [OK]
    OutputForm   [OK]

  PrecisionReal, Many Digits
  ==========================
    StandardForm   [OK]

  PrecisionReal, Many Accuracy
  ============================
    StandardForm   [OK]

  PrecisionReal, Zero_LowPrec
  ===========================
    StandardForm   [OK]

  PrecisionReal, Zero_LargePrec
  =============================
    StandardForm   [OK]

  PrecisionReal, Zero_Accuracy
  ============================
    StandardForm   [OK]

Graphics
========

  Disk
  ====
    StandardForm   [OK]
    OutputForm   [OK]

  Sphere
  ======
    StandardForm   [OK]
    OutputForm   [OK]

Parsing string form
===================

  RowBox
  ======
    StandardForm   [OK]

  FractionBox
  ===========
    StandardForm   [OK]

  FractionBox bracket
  ===================
    StandardForm   [OK]

  SqrtBox
  =======
    StandardForm   [OK]

  FormBox
  =======
    StandardForm   [OK]

@rocky
Copy link
Member

rocky commented Jan 2, 2026

There are a lot of changes here. I will try to pull this branch locally and go over it in detail tomorrow.

@rocky
Copy link
Member

rocky commented Jan 3, 2026

LGTM - I tried this out locally, but there are just way too many tests, and there are way too many changes to be able to verify this. I guess we'll make corrections down the line.

StandardForm:
expr: MakeBoxes[0.``30]
expect: "\"0``30.\""
msg: "In Mathics, precision is always an integer number."
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
msg: "In Mathics, precision is always an integer number."
msg: "In Mathics3, precision is always an integer number."

StandardForm:
expr: MakeBoxes[1.4`20]
expect: "\"1.4`20.\""
msg: "In Mathics, precision is always an integer number."
Copy link
Member

@rocky rocky Jan 3, 2026

Choose a reason for hiding this comment

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

Please let's use Mathics3 everywhere.

expect: "GraphicsBox[{DiskBox[{0, 0}, 1]}]"
OutputForm:
expr: "MakeBoxes[Graphics[{Disk[{0,0}, 1]}]//OutputForm]"
expect: InterpretationBox[PaneBox["\"-Graphics-\""], OutputForm[Graphics[{Disk[{0, 0}, 1]}]], Editable -> False]
Copy link
Member

@rocky rocky Jan 3, 2026

Choose a reason for hiding this comment

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

In wolframscript we don't see InterpretationBox, but instead GraphicsBox. Is this a notebook thing, and if so, the idea is that we follow notebook when there are discrepencies?

Copy link
Member

Choose a reason for hiding this comment

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

And when I try this in the current mathics3 I get:

In[1]= MakeBoxes[Graphics[{Disk[{0,0}, 1]}]//OutputForm]"
        "
Out[1]= 
         GraphicsBox[{DiskBox[{0, 0}, 1]}, AlignmentPoint → Center, AspectRatio → Automatic, Axes → False, AxesLabel → None, AxesOrigin → Automatic, AxesStyle → {}, Background → Automatic, BaseStyle → {}, BaselinePosition → Automatic, ContentSelectable → Automatic, CoordinatesToolOptions → Automatic, Epilog → {}, FormatType → TraditionalForm, Frame → False, FrameLabel → None, FrameStyle → {}, FrameTicks → Automatic, FrameTicksStyle → {}, GridLines → None, GridLinesStyle → {}, ImageMargins → 0., ImagePadding → All, ImageSize → Automatic, LabelStyle → {}, LogPlot → False, Method → Automatic, PlotLabel → None, PlotRange → Automatic, PlotRangeClipping → False, PlotRangePadding → Automatic, PlotRegion → Automatic, PreserveImageOptions → Automatic, Prolog → {}, RotateLabel → True, Ticks → Automatic, TicksStyle → {}]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, this is the kind of things I want to fix, after having a clear reference to do that.

Copy link
Member

Choose a reason for hiding this comment

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

If we are testing things that will have be changed later, it would be better to remove these or mark them skipped.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By the end of this month, I expect to have fixed this too, according to WMA standard.

@mmatera
Copy link
Contributor Author

mmatera commented Jan 3, 2026

The goal of all these tests (which mostly are tests that have been around for a while) is to detect differences between the output in Mathics and in WMA. Changes are most related to make the tests available also from both CLI, and adding a few structures that appear in the evaluation of these tests.

@mmatera mmatera merged commit 1aa6cc0 into master Jan 3, 2026
21 checks passed
@mmatera mmatera deleted the test_makeboxes branch January 3, 2026 17:23
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