Where are those patches? I can't find them in the main repository. Am I missing something?
Ondrej On Thu, May 28, 2009 at 6:53 AM, Fabian Pedregosa <fab...@fseoane.net> wrote: > > Fabian Pedregosa wrote: >> Ondrej Certik wrote: >>> +1 from me too. >> >> Thanks for the review. It's in >> >>> Ondrej >>> >>> On Wed, May 27, 2009 at 10:47 AM, TSidoti <tsid...@gmail.com> wrote: >>>> The changes look good. Thanks! >>>> >>>> -Thomas Sidoti >>>> >>>> On May 27, 10:33 am, Fabian Pedregosa <fab...@fseoane.net> wrote: >>>>> TSidoti wrote: >>>>>> I wasn't sure how to add attachments and stay on the same thread. >>>>>> I changed the comments to comments and removed the prettyxml from the >>>>>> mathml() function but kept it in the print_mathml function. >>>>>> I added two tests which will fail if we don't have the unescape. One >>>>>> way around unescaping is to keep it only in print_mathml and than >>>>>> relying on the user to unescape xml from the mathml() function. >>>>>> Also I couldn't find a list of all the constants anywhere in the >>>>>> documentation, so I may be missing some. >>>>>> -Thomas Sidoti >>>>>> On May 24, 5:01 pm, Thomas Sidoti <tsid...@gmail.com> wrote: >>>>>>> From d11d7e2c1a52af277ab14b95b49c1e320aa87206 Mon Sep 17 00:00:00 2001 >>>>>>> From: Thomas Sidoti <tsid...@gmail.com> >>>>>>> Date: Sun, 24 May 2009 16:46:27 -0400 >>>>>>> Subject: [PATCH 2/2] added tests, EulerGamma, removed pretty >>>>>>> --- >>>>>>> sympy/printing/mathml.py | 24 ++++++++++++++---------- >>>>>>> sympy/printing/tests/test_mathml.py | 8 +++++++- >>>>>>> 2 files changed, 21 insertions(+), 11 deletions(-) >>>>>>> diff --git a/sympy/printing/mathml.py b/sympy/printing/mathml.py >>>>>>> index d057b03..72aec44 100644 >>>>>>> --- a/sympy/printing/mathml.py >>>>>>> +++ b/sympy/printing/mathml.py >>>>>>> @@ -88,7 +88,7 @@ class MathMLPrinter(Printer): >>>>>>> x.appendChild(self._print(term)) >>>>>>> return x >>>>>>> - """This is complicated because we attempt to order then results in >>>>>>> order of Basic._compare_pretty and use minus instaed of negative""" >>>>>>> + #This is complicated because we attempt to order then results in >>>>>>> order >>>>>>> of Basic._compare_pretty and use minus instead of negative >>>>>>> def _print_Add(self, e): >>>>>>> args = list(e.args) >>>>>>> args.sort(Basic._compare_pretty) >>>>>>> @@ -99,12 +99,12 @@ class MathMLPrinter(Printer): >>>>>>> arg = args[i] >>>>>>> coeff, terms = arg.as_coeff_terms() >>>>>>> if(coeff.is_negative): >>>>>>> - """use minus""" >>>>>>> + #use minus >>>>>>> x = self.dom.createElement('apply') >>>>>>> x.appendChild(self.dom.createElement('minus')) >>>>>>> x.appendChild(lastProcessed) >>>>>>> x.appendChild(self._print(-arg)) >>>>>>> - """invert expression since this is now minused""" >>>>>>> + #invert expression since this is now minused >>>>>>> lastProcessed = x; >>>>>>> if(arg == args[-1]): >>>>>>> plusNodes.append(lastProcessed) >>>>>>> @@ -132,16 +132,16 @@ class MathMLPrinter(Printer): >>>>>>> def _print_Rational(self, e): >>>>>>> if e.q == 1: >>>>>>> - """don't divide""" >>>>>>> + #don't divide >>>>>>> x = self.dom.createElement('cn') >>>>>>> x.appendChild(self.dom.createTextNode(str(e.p))) >>>>>>> return x >>>>>>> x = self.dom.createElement('apply') >>>>>>> x.appendChild(self.dom.createElement('divide')) >>>>>>> - """numerator""" >>>>>>> + #numerator >>>>>>> xnum = self.dom.createElement('cn') >>>>>>> xnum.appendChild(self.dom.createTextNode(str(e.p))) >>>>>>> - """denomenator""" >>>>>>> + #denomenator >>>>>>> xdenom = self.dom.createElement('cn') >>>>>>> xdenom.appendChild(self.dom.createTextNode(str(e.q))) >>>>>>> x.appendChild(xnum) >>>>>>> @@ -165,10 +165,14 @@ class MathMLPrinter(Printer): >>>>>>> def _print_ImaginaryUnit(self,e): >>>>>>> return self.dom.createElement('imaginaryi') >>>>>>> + def _print_EulerGamma(self,e): >>>>>>> + x = self.dom.createElement('cn') >>>>>>> + x.appendChild(self.dom.createTextNode('γ')) >>>>> you can better use <eulergamma/>, >>>>> seehttp://www.w3.org/TR/MathML2/chapter4.html >>>>> at the end of page >>>>> >>>>>>> + return x; >>>>> no need to use ; at line end in python >>>>> >>>>>>> + >>>>>>> def _print_GoldenRatio(self,e): >>>>>>> x = self.dom.createElement('cn') >>>>>>> - """This is an html phi""" >>>>>>> - x.appendChild(self.dom.createTextNode('ϕ')) >>>>>>> + x.appendChild(self.dom.createTextNode('Φ')) >>>>>>> return x; >>>>> Putting here an entity (Φ) is not very helpful since for entity >>>>> resolution you would have to go to the DTD which is not shipped (nor >>>>> referenced) in our printer. My solution would be to simply print the >>>>> unicode version of this: >>>>> >>>>> x.appendChild(self.dom.createTextNode(u"\u03c6")) > > However, the ideal solution would be to insert "&x03c6;" instead of > u"\u03c6", which is the xml way of inserting a unicode character that's > independent from the encoding. But this does not work as Thomas pointed > out, so I'm rather inclined to post a bug report about this to > bugs.python.org ... > >>>>> >>>>> which is anyway what the entity Φ will be replaced with after >>>>> looking. That way we avoid having the call to saxutils.unescape >>>>> >>>>> I attach a patch consisting of both patches you sent squashed together + >>>>> my modifications. >>>>> >>>>> The attached patch is +1 from me, just tell me what you think. >>>>> >>>>> ~Fabian >>>>> >>>>> >>>>> >>>>>>> def _print_Exp1(self,e): >>>>>>> @@ -217,7 +221,7 @@ class MathMLPrinter(Printer): >>>>>>> return x >>>>>>> def _print_Pow(self, e): >>>>>>> - """Here we use root instead of power if the exponent is the >>>>>>> reciprocal of an integer""" >>>>>>> + #Here we use root instead of power if the exponent is the >>>>>>> reciprocal of an integer >>>>>>> if e.exp.is_Rational and e.exp.p == 1: >>>>>>> x = self.dom.createElement('apply') >>>>>>> x.appendChild(self.dom.createElement('root')) >>>>>>> @@ -291,7 +295,7 @@ class MathMLPrinter(Printer): >>>>>>> def mathml(expr): >>>>>>> """Returns the MathML representation of expr""" >>>>>>> s = MathMLPrinter() >>>>>>> - return saxutils.unescape(s._print(sympify(expr)).toprettyxml()) >>>>>>> + return saxutils.unescape(s._print(sympify(expr)).toxml()) >>>>>>> def print_mathml(expr): >>>>>>> """ >>>>>>> diff --git a/sympy/printing/tests/test_mathml.py >>>>>>> b/sympy/printing/tests/test_mathml.py >>>>>>> index 52aea8a..087656d 100644 >>>>>>> --- a/sympy/printing/tests/test_mathml.py >>>>>>> +++ b/sympy/printing/tests/test_mathml.py >>>>>>> @@ -1,4 +1,4 @@ >>>>>>> -from sympy import diff, Integral, Limit, sin, Symbol, Integer, >>>>>>> Rational, >>>>>>> cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh, E, >>>>>>> I, oo, >>>>>>> pi >>>>>>> +from sympy import diff, Integral, Limit, sin, Symbol, Integer, >>>>>>> Rational, >>>>>>> cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh, E, >>>>>>> I, oo, >>>>>>> pi, GoldenRatio, EulerGamma >>>>>>> from sympy.printing.mathml import mathml, MathMLPrinter >>>>>>> from xml.dom.minidom import parseString >>>>>>> @@ -110,6 +110,12 @@ def test_mathml_constants(): >>>>>>> mml = mp._print(pi) >>>>>>> assert mml.nodeName == 'pi' >>>>>>> + mml = mathml(GoldenRatio) >>>>>>> + assert mml == '<cn>Φ</cn>' >>>>>>> + >>>>>>> + mml = mathml(EulerGamma) >>>>>>> + assert mml == '<cn>γ</cn>' >>>>>>> + >>>>>>> def test_mathml_trig(): >>>>>>> mml = mp._print(sin(x)) >>>>>>> assert mml.childNodes[0].nodeName == 'sin' >>>>>>> -- >>>>>>> 1.5.6.5 >>>>>>> 0001-MathML-trig-functions-order-of-terms-roots-and-c.patch >>>>>>> 13KViewDownload >>>>>>> 0002-added-tests-EulerGamma-removed-pretty.patch >>>>>>> 6KViewDownload >>>>> >>>>> 0001-Extend-MathML-s-printer-with-trig-functions-order-o.patch >>>>> 10KViewDownload >>>>> >> >> >> > >> > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-patches" group. To post to this group, send email to sympy-patches@googlegroups.com To unsubscribe from this group, send email to sympy-patches+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy-patches?hl=en -~----------~----~----~----~------~----~------~--~---