From c8261eb6422015b7cf256bf0cbf291e83b0e2c5e Mon Sep 17 00:00:00 2001 From: Lafrite Date: Tue, 25 Feb 2014 16:52:18 +0100 Subject: [PATCH] add str in render --- pymath/render.py | 7 ++++--- pymath/renders.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pymath/render.py b/pymath/render.py index 4ff6c6c..cc9e1f6 100644 --- a/pymath/render.py +++ b/pymath/render.py @@ -15,7 +15,7 @@ class Render(object): PRIORITY = {"^": 4,"*" : 3, "/": 3, ":": 3, "+": 2, "-":2, "(": 1} - def __init__(self, op_infix = {}, op_postfix = {}, other = {}, join = " ", type_render = {int: str, Fraction: str, Polynom: str}): + def __init__(self, op_infix = {}, op_postfix = {}, other = {}, join = " ", type_render = {str: str, int: str, Fraction: str, Polynom: str}): """Initiate the render @param op_infix: the dictionnary of infix operator with how they have to be render @@ -117,7 +117,7 @@ class Render(object): and operande < 0: return 1 - # Si c'est un expression formelle + # Si c'est un polynom elif type(operande) == Polynom: if operator in ["*", "/", "^"]: if len(operande) > 1 \ @@ -190,7 +190,8 @@ class Render(object): """ return type(exp) == int \ or type(exp) == Fraction \ - or type(exp) == Polynom + or type(exp) == Polynom \ + or exp.isalpha() def isOperator(self, exp): """Check if the expression is in self.operators diff --git a/pymath/renders.py b/pymath/renders.py index e9a35e7..5ebc60c 100644 --- a/pymath/renders.py +++ b/pymath/renders.py @@ -53,7 +53,7 @@ def texMult(op1,op2): tex_infix = {"+": " + ", "-": " - ", "*": texMult , ":": ":", "^":"^"} tex_postfix = {"/": texSlash} tex_other = {"(": "(", ")": ")"} -tex_type_render = {int: str, Fraction: texFrac, Polynom: str} +tex_type_render = {str:str, int: str, Fraction: texFrac, Polynom: str} tex_render = Render(tex_infix, tex_postfix, tex_other, type_render = tex_type_render)