-
-
Notifications
You must be signed in to change notification settings - Fork 64
Fix evaluation of InterpretationBox with options #1607
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ae5533f
Fix evaluation of InterpretationBox with options
mmatera 30b1e71
add more comments
mmatera 40a0865
Update mathics/builtin/box/layout.py
rocky c65a874
typos
mmatera a02dec4
Merge remote-tracking branch 'origin/more_boxlayout_tweaks' into more…
mmatera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 are examples of this code getting used?
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 exampe is in
test.format.format_test.mThere 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.
That's generic test code. Where in the YAML though?
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, the YAML file contains the examples
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.
Yes, I figured that, but anything specific.
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.
When the evaluation is successful, the final expression shows the options in lexicographical order.
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.
Thanks for the information. This is sufficiently complicated and subtle that a comment should be added.
I've been trying to think of one, but I am not sure I fully understand.
Is the idea that reprs is either some sort of evaluatable expression (or is it just some of StyleBox)?
If it is in this former category, then we need to evaluate it to turn it into a box which will process and remove the options?
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.
This rule converts an
Expressionobject into aInterpretationBoxobject. Expression does not haveboxes_to_*methods, andInterpretationBoxdoes not have anevaluatemethod. In order for the conversion happens, the rule must match with the expression. But the expression we have is of the formInterpretationBox[boxed, expr, opt1_, opt2_,...].Also,
InterpretationBoxhas a HoldAll attribute, so if the first element is not a BoxElementMixin, we need to evaluate it first.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.
Ok. Let's add this as a comment. I can do that tomorrow, along with the other small doc changes.
There is a lot of code in this PR that feels mysterious and bottom-up, as opposed to there beings some higher-level principle that can be used to derive the details coded.
Maybe later we will have a simpler model for expressing InputForm and how that relates
IntrpretationBox. IF that happens, it might be that it fits so well that we don't need to make a test like this, or the test feels more obvious.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.
This mechanism of conversions has been around for a while, but probably requires better documentation. The main idea is that
MakeBoxes[]does not produceExpressionobjects, butBoxElementMixinobjects.*Boxexpressions should then be evaluated to these kind of objects. The problem that this PR tries to fix is that this conversion fails forInterpretationBoxexpressions having optional parameters.