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
111667de
Commit
111667de
authored
Nov 21, 2012
by
Александр
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UI delta and tests:
parent
33159824
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
+13
-4
common/lib/capa/capa/chem/miller.py
+13
-4
No files found.
common/lib/capa/capa/chem/miller.py
View file @
111667de
...
...
@@ -16,12 +16,13 @@ def section_to_fraction(distance):
to fraction. Return inverted fraction
"""
# import ipdb; ipdb.set_trace()
if
np
.
isnan
(
distance
):
# plane || to axis (or contains axis)
print
distance
,
0
# return inverted fration to a == nan == 1/0 => 0 / 1
return
fr
.
Fraction
(
0
,
1
)
elif
distance
==
0
:
# plane goes through origin
return
fr
.
Fraction
(
1
,
1
)
# ERROR, need shift of coordinates
elif
math
.
fabs
(
distance
)
<=
0.05
:
# plane goes through origin, 0.02 - UI delta
return
fr
.
Fraction
(
1
if
distance
>=
0
else
-
1
,
1
)
# ERROR, need shift of coordinates
else
:
# limit_denominator to closest nicest fraction
# import ipdb; ipdb.set_trace()
...
...
@@ -51,7 +52,7 @@ def sub_miller(sections):
# output = '(' + ''.join(map(str, map(decimal.Decimal, miller))) + ')'
# import ipdb; ipdb.set_trace()
output
=
'('
+
','
.
join
(
map
(
str
,
map
(
decimal
.
Decimal
,
miller
)))
+
')'
print
'Miller indices:'
,
output
#
print 'Miller indices:', output
return
output
...
...
@@ -252,9 +253,17 @@ class Test_Crystallography_Miller(unittest.TestCase):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["1.00", "0.00", "0.00"], ["1.00", "1.00", "1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(0,-1,1)'
,
'lattice'
:
'bcc'
}))
def
test_24
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.66", "0.00", "0.00"], ["0.00", "0.66", "0.00"], ["0.00", "0.00", "0.66"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(3,3,3)'
,
'lattice'
:
'bcc'
}))
def
test_25
(
self
):
user_input
=
u'{"lattice":"","points":[["0.00","0.00","0.01"],["1.00","1.00","0.01"],["0.00","1.00","1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(1,-1,1)'
,
'lattice'
:
''
}))
def
test_wrong_lattice
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["1.00", "0.00", "0.00"], ["1.00", "1.00", "1.00"]]}'
self
.
assertFalse
(
grade
(
user_input
,
{
'miller'
:
'(
0,-1,1
)'
,
'lattice'
:
'fcc'
}))
self
.
assertFalse
(
grade
(
user_input
,
{
'miller'
:
'(
3,3,3
)'
,
'lattice'
:
'fcc'
}))
def
suite
():
...
...
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