-
-
Notifications
You must be signed in to change notification settings - Fork 62
Tests for MakeBoxes #1579
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
Tests for MakeBoxes #1579
Conversation
test/builtin/test_makeboxes.py
Outdated
| ( | ||
| r"MakeBoxes[3.142`3]", | ||
| r"3.142`3", | ||
| "StandadForm with Prec real shows all the stored digits, and prec", |
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.
| "StandadForm with Prec real shows all the stored digits, and prec", | |
| "StandardForm with real precision shows all the stored digits, and precision", |
test/builtin/test_makeboxes.py
Outdated
| [ | ||
| (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."), |
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.
| (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."), |
test/builtin/test_makeboxes.py
Outdated
| ( | ||
| r"MakeBoxes[OutputForm[3.142`3]]", | ||
| r'InterpretationBox[PaneBox["3.14"], 3.14, Editable -> False]', | ||
| "OutputForm trims digits up to prec.", |
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.
| "OutputForm trims digits up to prec.", | |
| "OutputForm trims digits up to precision.", |
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 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.
838a77e to
b3984f3
Compare
test/builtin/test_makeboxes.py
Outdated
| ("MakeBoxes[x]", '"x"', "StandardForm"), | ||
| ( | ||
| "MakeBoxes[InputForm[x]]", | ||
| 'InterpretationBox[StyleBox["x", ShowStringCharacters -> True, NumberMarks -> True], InputForm[x], Editable -> True, AutoDelete -> True]', |
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.
WMA has x, instead of InputForm[x] and there are no quotes around "x" in StyleBox["x"]. What gives?
test/builtin/test_makeboxes.py
Outdated
| ), | ||
| ( | ||
| "MakeBoxes[OutputForm[x]]", | ||
| 'InterpretationBox[PaneBox[""x""], OutputForm[x], Editable -> False]', |
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.
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.
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.
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.
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 I see is:
InterpretationBox[PaneBox["\"x\"", BaselinePosition -> Baseline], x, Editable -> False]Note the extra backslashes. This is slightly different.
test/builtin/test_makeboxes.py
Outdated
| 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.", |
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.
Seems like a regression here.
|
With this change, we can do something like this: and compare with This is the output of the first command (using wolframscript): |
|
There are a lot of changes here. I will try to pull this branch locally and go over it in detail tomorrow. |
…SuperscriptBox with a nested expression.>>
c348028 to
308839c
Compare
|
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. |
Co-authored-by: R. Bernstein <[email protected]>
test/format/makeboxes_tests.yaml
Outdated
| StandardForm: | ||
| expr: MakeBoxes[0.``30] | ||
| expect: "\"0``30.\"" | ||
| msg: "In Mathics, precision is always an integer number." |
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.
| msg: "In Mathics, precision is always an integer number." | |
| msg: "In Mathics3, precision is always an integer number." |
test/format/makeboxes_tests.yaml
Outdated
| StandardForm: | ||
| expr: MakeBoxes[1.4`20] | ||
| expect: "\"1.4`20.\"" | ||
| msg: "In Mathics, precision is always an integer number." |
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 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] |
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 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?
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.
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 → {}]
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.
Yep, this is the kind of things I want to fix, after having a clear reference to do that.
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.
If we are testing things that will have be changed later, it would be better to remove these or mark them skipped.
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.
By the end of this month, I expect to have fixed this too, according to WMA standard.
Co-authored-by: R. Bernstein <[email protected]>
|
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. |
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.pyshould start to pass more tests as we make progress in driving the behavior to a one compatible with WMA.