예제 #1
0
파일: mathml.py 프로젝트: 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
예제 #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
예제 #3
0
파일: math.py 프로젝트: wgradl/ampform
 def __print_complex(self, printer: Printer) -> str:
     x = self.args[0]
     expr = self._evaluate_complex(x)
     return printer._print(expr)
예제 #4
0
파일: math.py 프로젝트: wgradl/ampform
 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}))))")
예제 #5
0
파일: math.py 프로젝트: wgradl/ampform
 def _latex(self, printer: Printer, *args: Any) -> str:
     x = printer._print(self.args[0])
     return Rf"\sqrt[\mathrm{{c}}]{{{x}}}"
예제 #6
0
 def doprint(self, expr):
     return Printer._print(self, expr)