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
changes to add root_notation flag in mathml.py. #15901
Conversation
✅ Hi, I am the SymPy bot (v136). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.4. Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
Thanks! The printing part looks good, but I do not think the logic with the settings are working. (Maybe you were waiting for the init task to be solved?) I have now merged #15906 which has a working init. If you merge this (will probably be easier if you remove both your init methods before merging master) you should be able to execute your code. Also, you can remove your default_setting. Once that is done, please add a few tests to show that the flag changes the behavior. (Maybe it doesn't work in the content printer. Probably the settings handling should have been put there, but I was a bit too quick to merge #15906 I realize, as I didn't want to stall this PR.) |
sympy/printing/mathml.py
Outdated
@@ -905,7 +920,7 @@ def mathml(expr, printer='content', **settings): | |||
return MathMLContentPrinter(settings).doprint(expr) | |||
|
|||
|
|||
def print_mathml(expr, printer='content', **settings): | |||
def print_mathml(expr, printer='content', symbol_names=None, root_notation=True, order=None): |
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.
It would be very useful if you can add all the settings from #15877 here. Starting with printer
and order
(to not break backwards compatibility) and then the rest in alphabetical order.
Even better if they are also added below, but here is the first priority.
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.
okay, i am adding those settings.
sympy/printing/mathml.py
Outdated
@@ -112,6 +115,12 @@ class MathMLContentPrinter(MathMLPrinterBase): | |||
""" | |||
printmethod = "_mathml_content" | |||
|
|||
def __init__(self, settings=None): |
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.
You can remove this and rely on the parent class instead I think.
sympy/printing/mathml.py
Outdated
@@ -466,6 +475,12 @@ class MathMLPresentationPrinter(MathMLPrinterBase): | |||
""" | |||
printmethod = "_mathml_presentation" | |||
|
|||
def __init__(self, settings=None): | |||
Printer.__init__(self, settings) |
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.
Here, it is better to call MathMLPrinterBase instead. However, this is just for future reference as this is already done in #15906. (Even better is super(MathMLPresentationPrinter, self).__init__(self, settings)
.)
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.
okay
The changes i made work for content printer as well. |
Ah, so |
I have added root_notation in _default_settings of MathMLPrinterBase. Now, should i make the changes so that this flag works for both presentation or content printing or just presentation? |
@shiksha11 make sure you resolve the conflicting file and add a test to support the changes you've made before you proceed ahead. |
sympy/printing/mathml.py
Outdated
@@ -466,7 +467,7 @@ class MathMLPresentationPrinter(MathMLPrinterBase): | |||
|
|||
def __init__(self, settings=None): | |||
MathMLPrinterBase.__init__(self, settings) | |||
|
|||
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.
Here are some spaces.
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.
removed those spaces.
Are there any tests which i can run locally to check for these errors related to spaces or code style?
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, python bin\test quality
on "Windows", bin/test quality
on "Linux". (Citation marks as exact usage will vary depending on so many things...)
Takes less than a minute so clearly worth it.
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.
Okay, thanks :)
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.
It is also possible to run a subset of the tests by replacing quality
with the module name, in this case printing
. One can also run only a specific test with the -k
flag, in your case -k test_presentation_printmethod
(using printing
as well will probably speed things up as not all tests are searched).
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 problem now is that the flag is passed when instantiating the printer, not in the
doprint
method. So you will need to instantiate a new printer with the flag. Probably makes sense to move it to a separate test as well to make it clear that it uses a different printer instantiation.
Yes, i was initially unsure about adding the test in the doprint method.
I added the missing import. If the tests pass it should be good to go. Thanks! |
The problem now is that the flag is passed when instantiating the printer, not in the |
I added that now. |
Primarily to get a new Azure run, which seems to have not started last time.
Thanks!! |
Did you understand the problem from the error messages ? |
Yes. From https://travis-ci.org/sympy/sympy/jobs/488910309
and later from https://travis-ci.org/sympy/sympy/jobs/489118673
Not sure why the Azure tests are not running though... |
Thanks! Now i understand how to interpret those messages. |
I merge it now. Thanks! |
Made Changes to fix issue #14033.
Added root_noatation flag in mathml.py.