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
4a76a629
Commit
4a76a629
authored
Jan 28, 2015
by
Adam Palay
Committed by
AlasdairSwan
Jan 28, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Fix tolerance broken"
This reverts commit
66b949b7
.
parent
e600d6e3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 additions
and
25 deletions
+1
-25
common/lib/capa/capa/tests/test_util.py
+0
-9
common/lib/capa/capa/util.py
+1
-16
No files found.
common/lib/capa/capa/tests/test_util.py
View file @
4a76a629
...
...
@@ -81,15 +81,6 @@ class UtilTest(unittest.TestCase):
self
.
assertFalse
(
result
)
result
=
compare_with_tolerance
(
infinity
,
infinity
,
'1.0'
,
False
)
self
.
assertTrue
(
result
)
# Test absolute tolerance for smaller values
result
=
compare_with_tolerance
(
100.01
,
100.0
,
0.01
,
False
)
self
.
assertTrue
(
result
)
result
=
compare_with_tolerance
(
100.001
,
100.0
,
0.001
,
False
)
self
.
assertTrue
(
result
)
result
=
compare_with_tolerance
(
100.01
,
100.0
,
'0.01
%
'
,
False
)
self
.
assertTrue
(
result
)
result
=
compare_with_tolerance
(
100.002
,
100.0
,
0.001
,
False
)
self
.
assertFalse
(
result
)
def
test_sanitize_html
(
self
):
"""
...
...
common/lib/capa/capa/util.py
View file @
4a76a629
...
...
@@ -5,7 +5,6 @@ import bleach
from
calc
import
evaluator
from
cmath
import
isinf
from
decimal
import
Decimal
#-----------------------------------------------------------------------------
#
# Utility functions used in CAPA responsetypes
...
...
@@ -68,21 +67,7 @@ def compare_with_tolerance(student_complex, instructor_complex, tolerance=defaul
else
:
# v1 and v2 are, in general, complex numbers:
# there are some notes about backward compatibility issue: see responsetypes.get_staff_ans()).
decimal_places
=
None
# count the "decimal_places" for "student_complex". e.g, for
# "student_complex" value "152.3667" the "decimal_places" will be
# 4 as there are 4 digits "3667" after decimal
if
isinstance
(
student_complex
,
float
):
decimal_places
=
Decimal
(
str
(
student_complex
))
.
as_tuple
()
.
exponent
*
-
1
# pylint: disable=E1103
abs_value
=
abs
(
student_complex
-
instructor_complex
)
# decimal_places could be NaN in some cases
if
decimal_places
and
isinstance
(
decimal_places
,
int
):
# abs_value contains 17 digits exponent value so
# round it up to "decimal_places"
abs_value
=
round
(
abs_value
,
decimal_places
)
return
abs_value
<=
tolerance
return
abs
(
student_complex
-
instructor_complex
)
<=
tolerance
def
contextualize_text
(
text
,
context
):
# private
...
...
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