Commit 1c3dcd99 by Peter Baratta

Some code fixes

Change some `is` comparison to `==`. Also, modify the `render_atom` method.
parent 28a1ca8a
......@@ -177,9 +177,9 @@ def eval_sum(parse_result):
total = 0.0
current_op = operator.add
for token in parse_result:
if token is '+':
if token == '+':
current_op = operator.add
elif token is '-':
elif token == '-':
current_op = operator.sub
else:
total = current_op(total, token)
......@@ -195,9 +195,9 @@ def eval_product(parse_result):
prod = 1.0
current_op = operator.mul
for token in parse_result:
if token is '*':
if token == '*':
current_op = operator.mul
elif token is '/':
elif token == '/':
current_op = operator.truediv
else:
prod = current_op(prod, token)
......
......@@ -253,16 +253,14 @@ def render_atom(children):
"""
Properly handle parens, otherwise this is trivial.
"""
parens = None
if children[0].latex in "([{":
# then len(children) == 3
parens = children[0].latex
children = [children[1]]
return LatexRendered(
children[0].latex,
parens,
children[0].tall
)
if len(children) == 3:
return LatexRendered(
children[1].latex,
parens=children[0].latex,
tall=children[1].tall
)
else:
return children[0]
def latex_preview(math_expr, variables=(), functions=(), case_sensitive=False):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment