Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 1593 by john.theman.connor: print_Basic, print_mathml, etc. are  
broken
http://code.google.com/p/sympy/issues/detail?id=1593

This appears to be related to bugs 1311, 1310, and 1273.

For example:

from sympy import arg, I
from sympy.printing.mathml import mathml

mathml(arg(I))


gives the following trace:

/var/lib/python-support/python2.5/sympy/printing/mathml.pyc in mathml(expr)
     132     """Returns the MathML representation of expr"""
     133     s = MathMLPrinter()
--> 134     return s.doprint(sympify(expr))
     135
     136 def print_mathml(expr):

/var/lib/python-support/python2.5/sympy/printing/mathml.pyc in  
doprint(self, e)
      11
      12     def doprint(self, e):
---> 13         return self._print(e).toprettyxml()
      14
      15     def mathml_tag(self, e):

/var/lib/python-support/python2.5/sympy/printing/printer.pyc in
_print(self, expr, *args)
      93         for cls in type(expr).__mro__:
      94             if hasattr(self, '_print_'+cls.__name__):
---> 95                 res = getattr(self, '_print_'+cls.__name__)(expr,
*args)
      96                 break
      97

/var/lib/python-support/python2.5/sympy/printing/mathml.pyc in
_print_AssocOp(self, e)
     126         x.appendChild(x_1)
     127         for arg in e.args:
--> 128             x.appendChild(self._print(arg))
     129         return x
     130

/var/lib/python-support/python2.5/sympy/printing/printer.pyc in
_print(self, expr, *args)
      93         for cls in type(expr).__mro__:
      94             if hasattr(self, '_print_'+cls.__name__):
---> 95                 res = getattr(self, '_print_'+cls.__name__)(expr,
*args)
      96                 break
      97

/var/lib/python-support/python2.5/sympy/printing/mathml.pyc in
_print_Basic(self, e)
     117     def _print_Basic(self, e):
     118         x = self.dom.createElement(self.mathml_tag(e))
--> 119         for arg in e:
     120             x.appendChild(self._print(arg))
     121         return x

TypeError: 'Pi' object
/var/lib/python-support/python2.5/sympy/printing/mathml.pyc in mathml(expr)
     132     """Returns the MathML representation of expr"""
     133     s = MathMLPrinter()
--> 134     return s.doprint(sympify(expr))
     135
     136 def print_mathml(expr):

/var/lib/python-support/python2.5/sympy/printing/mathml.pyc in  
doprint(self, e)
      11
      12     def doprint(self, e):
---> 13         return self._print(e).toprettyxml()
      14
      15     def mathml_tag(self, e):

/var/lib/python-support/python2.5/sympy/printing/printer.pyc in
_print(self, expr, *args)
      93         for cls in type(expr).__mro__:
      94             if hasattr(self, '_print_'+cls.__name__):
---> 95                 res = getattr(self, '_print_'+cls.__name__)(expr,
*args)
      96                 break
      97

/var/lib/python-support/python2.5/sympy/printing/mathml.pyc in
_print_AssocOp(self, e)
     126         x.appendChild(x_1)
     127         for arg in e.args:
--> 128             x.appendChild(self._print(arg))
     129         return x
     130

/var/lib/python-support/python2.5/sympy/printing/printer.pyc in
_print(self, expr, *args)
      93         for cls in type(expr).__mro__:
      94             if hasattr(self, '_print_'+cls.__name__):
---> 95                 res = getattr(self, '_print_'+cls.__name__)(expr,
*args)
      96                 break
      97

/var/lib/python-support/python2.5/sympy/printing/mathml.pyc in
_print_Basic(self, e)
     117     def _print_Basic(self, e):
     118         x = self.dom.createElement(self.mathml_tag(e))
--> 119         for arg in e:
     120             x.appendChild(self._print(arg))
     121         return x

TypeError: 'Pi' object is not iterable


I am not sure what the situation is exactly.  It may have something to do
with "pi" being a self closing tag.  In any case I am able to resolve the
issue by changing _print_Basic:

     def _print_Basic(self, e):
         x = self.dom.createElement(self.mathml_tag(e))
         if getattr(e, '__iter__', True):
             for arg in e:
                 x.appendChild(self._print(arg))
         return xeturn x

But as you can see this is less then ideal.

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com
To unsubscribe from this group, send email to 
sympy-issues+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to