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
b9af428b
Commit
b9af428b
authored
Sep 20, 2012
by
ichuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
formula.py handle imaginary correctly; symmath_check add numerical option
parent
f1e5d697
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
lms/lib/symmath/formula.py
+1
-2
lms/lib/symmath/symmath_check.py
+8
-0
No files found.
lms/lib/symmath/formula.py
View file @
b9af428b
...
...
@@ -409,8 +409,7 @@ class formula(object):
if
'hat'
in
usym
:
sym
=
my_sympify
(
usym
)
else
:
if
usym
==
'i'
:
print
"options="
,
self
.
options
if
usym
==
'i'
and
'imaginary'
in
self
.
options
:
# i = sqrt(-1)
if
usym
==
'i'
and
self
.
options
is
not
None
and
'imaginary'
in
self
.
options
:
# i = sqrt(-1)
sym
=
sympy
.
I
else
:
sym
=
sympy
.
Symbol
(
str
(
usym
))
...
...
lms/lib/symmath/symmath_check.py
View file @
b9af428b
...
...
@@ -175,6 +175,7 @@ def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None
do_matrix
=
'matrix'
in
(
options
or
''
)
do_qubit
=
'qubit'
in
(
options
or
''
)
do_imaginary
=
'imaginary'
in
(
options
or
''
)
do_numerical
=
'numerical'
in
(
options
or
''
)
# parse expected answer
try
:
...
...
@@ -196,6 +197,13 @@ def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None
msg
+=
'<p>You entered:
%
s</p>'
%
to_latex
(
fans
)
return
{
'ok'
:
False
,
'msg'
:
msg
}
if
do_numerical
:
# numerical answer expected - force numerical comparison
if
abs
(
abs
(
fans
-
fexpect
)
/
fexpect
)
<
threshold
:
return
{
'ok'
:
True
,
'msg'
:
msg
}
else
:
msg
+=
'<p>You entered:
%
s (note that a numerical answer is expected)</p>'
%
to_latex
(
fans
)
return
{
'ok'
:
False
,
'msg'
:
msg
}
if
fexpect
==
fans
:
msg
+=
'<p>You entered:
%
s</p>'
%
to_latex
(
fans
)
return
{
'ok'
:
True
,
'msg'
:
msg
}
...
...
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