Ejemplo n.º 1
0
Archivo: mathml.py Proyecto: cklb/sympy
 def doprint(self, expr):
     """
     Prints the expression as MathML.
     """
     mathML = Printer._print(self, expr)
     unistr = mathML.toxml()
     xmlbstr = unistr.encode('ascii', 'xmlcharrefreplace')
     res = xmlbstr.decode()
     return res
Ejemplo n.º 2
0
 def doprint(self, expr):
     """
     Prints the expression as MathML.
     """
     mathML = Printer._print(self, expr)
     unistr = mathML.toxml()
     xmlbstr = unistr.encode('ascii', 'xmlcharrefreplace')
     res = xmlbstr.decode()
     return res
Ejemplo n.º 3
0
 def __print_complex(self, printer: Printer) -> str:
     x = self.args[0]
     expr = self._evaluate_complex(x)
     return printer._print(expr)
Ejemplo n.º 4
0
 def _pythoncode(self, printer: Printer, *args: Any) -> str:
     printer.module_imports["cmath"].add("sqrt as csqrt")
     x = printer._print(self.args[0])
     return (f"(((1j*sqrt(-{x}))"
             f" if isinstance({x}, (float, int)) and ({x} < 0)"
             f" else (csqrt({x}))))")
Ejemplo n.º 5
0
 def _latex(self, printer: Printer, *args: Any) -> str:
     x = printer._print(self.args[0])
     return Rf"\sqrt[\mathrm{{c}}]{{{x}}}"
Ejemplo n.º 6
0
 def doprint(self, expr):
     return Printer._print(self, expr)