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
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
def __print_complex(self, printer: Printer) -> str: x = self.args[0] expr = self._evaluate_complex(x) return printer._print(expr)
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}))))")
def _latex(self, printer: Printer, *args: Any) -> str: x = printer._print(self.args[0]) return Rf"\sqrt[\mathrm{{c}}]{{{x}}}"
def doprint(self, expr): return Printer._print(self, expr)