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
a1db394b
Commit
a1db394b
authored
May 10, 2013
by
Peter Baratta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test for infinity in numerical and formula responses
parent
f970bbd1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
common/lib/capa/capa/responsetypes.py
+0
-2
common/lib/capa/capa/util.py
+5
-1
No files found.
common/lib/capa/capa/responsetypes.py
View file @
a1db394b
...
@@ -1869,8 +1869,6 @@ class FormulaResponse(LoncapaResponse):
...
@@ -1869,8 +1869,6 @@ class FormulaResponse(LoncapaResponse):
log
.
debug
(
'formularesponse: error
%
s in formula'
%
err
)
log
.
debug
(
'formularesponse: error
%
s in formula'
%
err
)
raise
StudentInputError
(
"Invalid input: Could not parse '
%
s' as a formula"
%
raise
StudentInputError
(
"Invalid input: Could not parse '
%
s' as a formula"
%
cgi
.
escape
(
given
))
cgi
.
escape
(
given
))
if
numpy
.
isnan
(
student_result
)
or
numpy
.
isinf
(
student_result
):
return
"incorrect"
if
not
compare_with_tolerance
(
student_result
,
instructor_result
,
self
.
tolerance
):
if
not
compare_with_tolerance
(
student_result
,
instructor_result
,
self
.
tolerance
):
return
"incorrect"
return
"incorrect"
return
"correct"
return
"correct"
...
...
common/lib/capa/capa/util.py
View file @
a1db394b
from
.calc
import
evaluator
,
UndefinedVariable
from
.calc
import
evaluator
,
UndefinedVariable
from
cmath
import
isinf
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#
#
...
@@ -20,8 +21,11 @@ def compare_with_tolerance(v1, v2, tol):
...
@@ -20,8 +21,11 @@ def compare_with_tolerance(v1, v2, tol):
tolerance
=
tolerance_rel
*
max
(
abs
(
v1
),
abs
(
v2
))
tolerance
=
tolerance_rel
*
max
(
abs
(
v1
),
abs
(
v2
))
else
:
else
:
tolerance
=
evaluator
(
dict
(),
dict
(),
tol
)
tolerance
=
evaluator
(
dict
(),
dict
(),
tol
)
return
abs
(
v1
-
v2
)
<=
tolerance
if
isinf
(
v1
)
or
isinf
(
v2
):
return
v1
==
v2
# because the other numerical comparison does not work with infinities
else
:
return
abs
(
v1
-
v2
)
<=
tolerance
def
contextualize_text
(
text
,
context
):
# private
def
contextualize_text
(
text
,
context
):
# private
''' Takes a string with variables. E.g. $a+$b.
''' Takes a string with variables. E.g. $a+$b.
...
...
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