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
1f7feb74
Commit
1f7feb74
authored
Oct 12, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix arrows list
parent
a20f0185
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
common/lib/capa/capa/chem/chemcalc.py
+3
-3
No files found.
common/lib/capa/capa/chem/chemcalc.py
View file @
1f7feb74
...
...
@@ -14,6 +14,7 @@ from pyparsing import (Literal, Keyword, Word, nums, StringEnd, Optional,
import
nltk
from
nltk.tree
import
Tree
ARROWS
=
(
'<->'
,
'->'
)
## Defines a simple pyparsing tokenizer for chemical equations
elements
=
[
'Ac'
,
'Ag'
,
'Al'
,
'Am'
,
'Ar'
,
'As'
,
'At'
,
'Au'
,
'B'
,
'Ba'
,
'Be'
,
...
...
@@ -363,8 +364,7 @@ def split_on_arrow(eq):
Return left, arrow, right.
"""
# order matters -- need to try <-> first
arrows
=
(
'<->'
,
'->'
)
for
arrow
in
arrows
:
for
arrow
in
ARROWS
:
left
,
a
,
right
=
eq
.
partition
(
arrow
)
if
a
!=
''
:
return
left
,
a
,
right
...
...
@@ -398,7 +398,7 @@ def chemical_equations_equal(eq1, eq2, exact=False):
left2
,
arrow2
,
right2
=
split_on_arrow
(
eq2
)
if
arrow1
==
''
or
arrow2
==
''
:
raise
ParseException
(
"Could not find arrow. Legal arrows: {0}"
.
format
(
arrows
))
raise
ParseException
(
"Could not find arrow. Legal arrows: {0}"
.
format
(
ARROWS
))
# TODO: may want to be able to give student helpful feedback about why things didn't work.
if
arrow1
!=
arrow2
:
...
...
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