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
e65a017c
Commit
e65a017c
authored
Feb 27, 2013
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added additional unit tests for symmath library that verify
symmath_check for simple symbolic input strings.
parent
850d9846
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
50 deletions
+58
-50
lms/lib/symmath/symmath_check.py
+0
-50
lms/lib/symmath/test_symmath_check.py
+58
-0
No files found.
lms/lib/symmath/symmath_check.py
View file @
e65a017c
...
@@ -325,53 +325,3 @@ def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None
...
@@ -325,53 +325,3 @@ def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None
msg
+=
'<hr>'
msg
+=
'<hr>'
return
{
'ok'
:
False
,
'msg'
:
msg
,
'ex'
:
fexpect
,
'got'
:
fsym
}
return
{
'ok'
:
False
,
'msg'
:
msg
,
'ex'
:
fexpect
,
'got'
:
fsym
}
#-----------------------------------------------------------------------------
# tests
def
sctest1
():
x
=
"1/2*(1+(k_e* Q* q)/(m *g *h^2))"
y
=
'''
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mstyle displaystyle="true">
<mfrac>
<mn>1</mn>
<mn>2</mn>
</mfrac>
<mrow>
<mo>(</mo>
<mn>1</mn>
<mo>+</mo>
<mfrac>
<mrow>
<msub>
<mi>k</mi>
<mi>e</mi>
</msub>
<mo>⋅</mo>
<mi>Q</mi>
<mo>⋅</mo>
<mi>q</mi>
</mrow>
<mrow>
<mi>m</mi>
<mo>⋅</mo>
<mrow>
<mi>g</mi>
<mo>⋅</mo>
</mrow>
<msup>
<mi>h</mi>
<mn>2</mn>
</msup>
</mrow>
</mfrac>
<mo>)</mo>
</mrow>
</mstyle>
</math>
'''
.
strip
()
z
=
"1/2(1+(k_e* Q* q)/(m *g *h^2))"
r
=
sympy_check2
(
x
,
z
,
{
'a'
:
z
,
'a_fromjs'
:
y
},
'a'
)
return
r
lms/lib/symmath/test_symmath_check.py
View file @
e65a017c
...
@@ -10,6 +10,64 @@ class SymmathCheckTest(TestCase):
...
@@ -10,6 +10,64 @@ class SymmathCheckTest(TestCase):
number_list
=
[
i
+
0.01
for
i
in
range
(
-
100
,
100
)]
number_list
=
[
i
+
0.01
for
i
in
range
(
-
100
,
100
)]
self
.
_symmath_check_numbers
(
number_list
)
self
.
_symmath_check_numbers
(
number_list
)
def
test_symmath_check_same_symbols
(
self
):
expected_str
=
"x+2*y"
dynamath
=
'''
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mstyle displaystyle="true">
<mrow>
<mi>x</mi>
<mo>+</mo>
<mn>2</mn>
<mo>*</mo>
<mi>y</mi>
</mrow>
</mstyle>
</math>'''
.
strip
()
# Expect that the exact same symbolic string is marked correct
result
=
symmath_check
(
expected_str
,
expected_str
,
dynamath
=
[
dynamath
])
self
.
assertTrue
(
'ok'
in
result
and
result
[
'ok'
])
def
test_symmath_check_equivalent_symbols
(
self
):
expected_str
=
"x+2*y"
input_str
=
"x+y+y"
dynamath
=
'''
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mstyle displaystyle="true">
<mrow>
<mi>x</mi>
<mo>+</mo>
<mi>y</mi>
<mo>+</mo>
<mi>y</mi>
</mrow>
</mstyle>
</math>'''
.
strip
()
# Expect that equivalent symbolic strings are marked correct
result
=
symmath_check
(
expected_str
,
input_str
,
dynamath
=
[
dynamath
])
self
.
assertTrue
(
'ok'
in
result
and
result
[
'ok'
])
def
test_symmath_check_different_symbols
(
self
):
expected_str
=
"0"
input_str
=
"x+y"
dynamath
=
'''
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mstyle displaystyle="true">
<mrow>
<mi>x</mi>
<mo>+</mo>
<mi>y</mi>
</mrow>
</mstyle>
</math>'''
.
strip
()
# Expect that an incorrect response is marked incorrect
result
=
symmath_check
(
expected_str
,
input_str
,
dynamath
=
[
dynamath
])
self
.
assertTrue
(
'ok'
in
result
and
not
result
[
'ok'
])
self
.
assertFalse
(
'fail'
in
result
[
'msg'
])
def
_symmath_check_numbers
(
self
,
number_list
):
def
_symmath_check_numbers
(
self
,
number_list
):
for
n
in
number_list
:
for
n
in
number_list
:
...
...
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