Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
7f06a313
Commit
7f06a313
authored
May 27, 2014
by
Jason Swails
Browse files
Fix comparison test in TestAmberInpcrdFile to compare sequences element by
element.
parent
073ea181
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
15 deletions
+22
-15
wrappers/python/tests/TestAmberInpcrdFile.py
wrappers/python/tests/TestAmberInpcrdFile.py
+22
-15
No files found.
wrappers/python/tests/TestAmberInpcrdFile.py
View file @
7f06a313
...
...
@@ -5,41 +5,48 @@ from simtk.openmm import *
from
simtk.unit
import
*
import
simtk.openmm.app.element
as
elem
def
compareByElement
(
array1
,
array2
,
cmp
):
for
x
,
y
in
zip
(
array1
,
array2
):
cmp
(
x
,
y
)
class
TestAmberInpcrdFile
(
unittest
.
TestCase
):
"""Test the Amber inpcrd file parser"""
def
test_CrdVelBox
(
self
):
""" Test parsing ASCII restarts with crds, vels, and box """
cmp
=
self
.
assertAlmostEqual
inpcrd
=
AmberInpcrdFile
(
'systems/crds_vels_box.rst7'
)
self
.
assertEqual
(
len
(
inpcrd
.
coordinate
s
),
2101
)
self
.
assertAlmostEqual
(
inpcrd
.
coordinate
s
[
-
1
].
value_in_unit
(
angstroms
),
[
3.5958082
,
8.4176792
,
-
8.2954064
])
self
.
assertAlmostEqual
(
inpcrd
.
velocities
[
-
1
].
value_in_unit
(
angstroms
/
picoseconds
),
[
0.3091332
*
20.455
,
0.7355925
*
20.455
,
-
0.1206961
*
20.455
])
self
.
assertAlmostEqual
(
inpcrd
.
boxVectors
[
0
].
value_in_unit
(
angstroms
),
[
30.2642725
,
0.0
,
0.0
])
self
.
assertEqual
(
len
(
inpcrd
.
position
s
),
2101
)
compareByElement
(
inpcrd
.
position
s
[
-
1
].
value_in_unit
(
angstroms
),
[
3.5958082
,
8.4176792
,
-
8.2954064
]
,
cmp
)
compareByElement
(
inpcrd
.
velocities
[
-
1
].
value_in_unit
(
angstroms
/
picoseconds
),
[
0.3091332
*
20.455
,
0.7355925
*
20.455
,
-
0.1206961
*
20.455
]
,
cmp
)
compareByElement
(
inpcrd
.
boxVectors
[
0
].
value_in_unit
(
angstroms
),
[
30.2642725
,
0.0
,
0.0
]
,
cmp
)
def
test_NetCDF
(
self
):
""" Test NetCDF restart file parsing """
cmp
=
self
.
assertAlmostEqual
try
:
from
scipy.io
import
netcdf
except
ImportError
:
print
(
'Not testing NetCDF file parser... scipy cannot be found'
)
else
:
inpcrd
=
AmberInpcrdFile
(
'systems/amber.ncrst'
)
self
.
assertEqual
(
len
(
inpcrd
.
coordinates
),
2101
)
self
.
assertAlmostEqual
(
inpcrd
.
coordinates
[
0
].
value_in_unit
(
angstroms
),
[
6.82122492718229
,
6.6276250662042
,
-
8.51668999892245
])
self
.
assertAlmostEqual
(
inpcrd
.
velocities
[
-
1
].
value_in_unit
(
angstroms
/
picosecond
),
[
0.349702202733541
*
20.455
,
0.391525333168534
*
20.455
,
0.417941679767662
*
20.455
])
self
.
assertEqual
(
len
(
inpcrd
.
positions
),
2101
)
compareByElement
(
inpcrd
.
positions
[
0
].
value_in_unit
(
angstroms
),
[
6.82122492718229
,
6.6276250662042
,
-
8.51668999892245
],
cmp
)
compareByElement
(
inpcrd
.
velocities
[
-
1
].
value_in_unit
(
angstroms
/
picosecond
),
[
0.349702202733541
*
20.455
,
0.391525333168534
*
20.455
,
0.417941679767662
*
20.455
],
cmp
)
self
.
assertAlmostEqual
(
inpcrd
.
boxVectors
[
0
][
0
].
value_in_unit
(
angstroms
),
30.2642725
)
30.2642725
,
places
=
6
)
def
test_CrdBox
(
self
):
""" Test parsing ASCII restarts with only crds and box """
inpcrd
=
AmberInpcrdFile
(
'systems/crds_box.rst7'
)
self
.
assertEqual
(
len
(
inpcrd
.
coordinate
s
),
18660
)
self
.
assertEqual
(
len
(
inpcrd
.
position
s
),
18660
)
self
.
assertTrue
(
inpcrd
.
velocities
is
None
)
self
.
assertTrue
(
inpcrd
.
boxVectors
is
not
None
)
...
...
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