add str in render

This commit is contained in:
Lafrite 2014-02-25 16:52:18 +01:00
parent ccd388c87c
commit c8261eb642
2 changed files with 5 additions and 4 deletions

View File

@ -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

View File

@ -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)