Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
1c3dcd99
Commit
1c3dcd99
authored
Jul 25, 2013
by
Peter Baratta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some code fixes
Change some `is` comparison to `==`. Also, modify the `render_atom` method.
parent
28a1ca8a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
12 deletions
+10
-12
common/lib/calc/calc.py
+4
-4
common/lib/calc/preview.py
+6
-8
No files found.
common/lib/calc/calc.py
View file @
1c3dcd99
...
@@ -177,9 +177,9 @@ def eval_sum(parse_result):
...
@@ -177,9 +177,9 @@ def eval_sum(parse_result):
total
=
0.0
total
=
0.0
current_op
=
operator
.
add
current_op
=
operator
.
add
for
token
in
parse_result
:
for
token
in
parse_result
:
if
token
is
'+'
:
if
token
==
'+'
:
current_op
=
operator
.
add
current_op
=
operator
.
add
elif
token
is
'-'
:
elif
token
==
'-'
:
current_op
=
operator
.
sub
current_op
=
operator
.
sub
else
:
else
:
total
=
current_op
(
total
,
token
)
total
=
current_op
(
total
,
token
)
...
@@ -195,9 +195,9 @@ def eval_product(parse_result):
...
@@ -195,9 +195,9 @@ def eval_product(parse_result):
prod
=
1.0
prod
=
1.0
current_op
=
operator
.
mul
current_op
=
operator
.
mul
for
token
in
parse_result
:
for
token
in
parse_result
:
if
token
is
'*'
:
if
token
==
'*'
:
current_op
=
operator
.
mul
current_op
=
operator
.
mul
elif
token
is
'/'
:
elif
token
==
'/'
:
current_op
=
operator
.
truediv
current_op
=
operator
.
truediv
else
:
else
:
prod
=
current_op
(
prod
,
token
)
prod
=
current_op
(
prod
,
token
)
...
...
common/lib/calc/preview.py
View file @
1c3dcd99
...
@@ -253,16 +253,14 @@ def render_atom(children):
...
@@ -253,16 +253,14 @@ def render_atom(children):
"""
"""
Properly handle parens, otherwise this is trivial.
Properly handle parens, otherwise this is trivial.
"""
"""
parens
=
None
if
len
(
children
)
==
3
:
if
children
[
0
]
.
latex
in
"([{"
:
# then len(children) == 3
parens
=
children
[
0
]
.
latex
children
=
[
children
[
1
]]
return
LatexRendered
(
return
LatexRendered
(
children
[
0
]
.
latex
,
children
[
1
]
.
latex
,
parens
,
parens
=
children
[
0
]
.
latex
,
children
[
0
]
.
tall
tall
=
children
[
1
]
.
tall
)
)
else
:
return
children
[
0
]
def
latex_preview
(
math_expr
,
variables
=
(),
functions
=
(),
case_sensitive
=
False
):
def
latex_preview
(
math_expr
,
variables
=
(),
functions
=
(),
case_sensitive
=
False
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment