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
b665dfcb
Commit
b665dfcb
authored
Sep 01, 2015
by
peastman
Browse files
Merge pull request #1083 from rmcgibbo/wip-single-23-codebase
Single py2/3 codebase
parents
69a3f678
83d0e5e3
Changes
43
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
40 deletions
+37
-40
wrappers/python/simtk/unit/unit.py
wrappers/python/simtk/unit/unit.py
+10
-13
wrappers/python/tests/TestAmberPrmtopFile.py
wrappers/python/tests/TestAmberPrmtopFile.py
+19
-19
wrappers/python/tests/TestCharmmFiles.py
wrappers/python/tests/TestCharmmFiles.py
+8
-8
No files found.
wrappers/python/simtk/unit/unit.py
View file @
b665dfcb
...
@@ -102,10 +102,10 @@ class Unit(object):
...
@@ -102,10 +102,10 @@ class Unit(object):
# TODO - also handle non-simple units, i.e. units with multiple BaseUnits/ScaledUnits
# TODO - also handle non-simple units, i.e. units with multiple BaseUnits/ScaledUnits
assert
len
(
self
.
_top_base_units
)
==
1
assert
len
(
self
.
_top_base_units
)
==
1
assert
len
(
self
.
_scaled_units
)
==
0
assert
len
(
self
.
_scaled_units
)
==
0
dimension
=
self
.
_top_base_units
.
iterkeys
().
next
(
)
dimension
=
next
(
iter
(
self
.
_top_base_units
)
)
base_unit_dict
=
self
.
_top_base_units
[
dimension
]
base_unit_dict
=
self
.
_top_base_units
[
dimension
]
assert
len
(
base_unit_dict
)
==
1
assert
len
(
base_unit_dict
)
==
1
parent_base_unit
=
base_unit_dict
.
iterkeys
().
next
(
)
parent_base_unit
=
next
(
iter
(
base_unit_dict
)
)
parent_exponent
=
base_unit_dict
[
parent_base_unit
]
parent_exponent
=
base_unit_dict
[
parent_base_unit
]
new_base_unit
=
BaseUnit
(
parent_base_unit
.
dimension
,
name
,
symbol
)
new_base_unit
=
BaseUnit
(
parent_base_unit
.
dimension
,
name
,
symbol
)
# BaseUnit scale might be different depending on exponent
# BaseUnit scale might be different depending on exponent
...
@@ -121,10 +121,8 @@ class Unit(object):
...
@@ -121,10 +121,8 @@ class Unit(object):
Yields (BaseDimension, exponent) tuples comprising this unit.
Yields (BaseDimension, exponent) tuples comprising this unit.
"""
"""
# There might be two units with the same dimension? No.
# There might be two units with the same dimension? No.
for
dimension
in
sorted
(
self
.
_all_base_units
.
iterkeys
()):
for
dimension
in
sorted
(
self
.
_all_base_units
.
keys
()):
exponent
=
0
exponent
=
sum
(
self
.
_all_base_units
[
dimension
].
values
())
for
base_unit
in
sorted
(
self
.
_all_base_units
[
dimension
].
iterkeys
()):
exponent
+=
self
.
_all_base_units
[
dimension
][
base_unit
]
if
exponent
!=
0
:
if
exponent
!=
0
:
yield
(
dimension
,
exponent
)
yield
(
dimension
,
exponent
)
...
@@ -135,8 +133,8 @@ class Unit(object):
...
@@ -135,8 +133,8 @@ class Unit(object):
There might be multiple BaseUnits with the same dimension.
There might be multiple BaseUnits with the same dimension.
"""
"""
for
dimension
in
sorted
(
self
.
_all_base_units
.
iter
keys
()):
for
dimension
in
sorted
(
self
.
_all_base_units
.
keys
()):
for
base_unit
in
sorted
(
self
.
_all_base_units
[
dimension
].
iter
keys
()):
for
base_unit
in
sorted
(
self
.
_all_base_units
[
dimension
].
keys
()):
exponent
=
self
.
_all_base_units
[
dimension
][
base_unit
]
exponent
=
self
.
_all_base_units
[
dimension
][
base_unit
]
yield
(
base_unit
,
exponent
)
yield
(
base_unit
,
exponent
)
...
@@ -144,8 +142,8 @@ class Unit(object):
...
@@ -144,8 +142,8 @@ class Unit(object):
"""
"""
Yields (BaseUnit, exponent) tuples in this Unit, excluding those within BaseUnits.
Yields (BaseUnit, exponent) tuples in this Unit, excluding those within BaseUnits.
"""
"""
for
dimension
in
sorted
(
self
.
_top_base_units
.
iter
keys
()):
for
dimension
in
sorted
(
self
.
_top_base_units
.
keys
()):
for
unit
in
sorted
(
self
.
_top_base_units
[
dimension
].
iter
keys
()):
for
unit
in
sorted
(
self
.
_top_base_units
[
dimension
].
keys
()):
exponent
=
self
.
_top_base_units
[
dimension
][
unit
]
exponent
=
self
.
_top_base_units
[
dimension
][
unit
]
yield
(
unit
,
exponent
)
yield
(
unit
,
exponent
)
...
@@ -518,7 +516,7 @@ class ScaledUnit(object):
...
@@ -518,7 +516,7 @@ class ScaledUnit(object):
self
.
symbol
=
symbol
self
.
symbol
=
symbol
def
__iter__
(
self
):
def
__iter__
(
self
):
for
dim
in
sorted
(
self
.
base_units
.
iter
keys
()):
for
dim
in
sorted
(
self
.
base_units
.
keys
()):
yield
self
.
base_units
[
dim
]
yield
self
.
base_units
[
dim
]
def
iter_base_units
(
self
):
def
iter_base_units
(
self
):
...
@@ -602,8 +600,7 @@ class UnitSystem(object):
...
@@ -602,8 +600,7 @@ class UnitSystem(object):
if
not
len
(
self
.
base_units
)
==
len
(
self
.
units
):
if
not
len
(
self
.
base_units
)
==
len
(
self
.
units
):
raise
ArithmeticError
(
"UnitSystem must have same number of units as base dimensions"
)
raise
ArithmeticError
(
"UnitSystem must have same number of units as base dimensions"
)
# self.dimensions is a dict of {BaseDimension: index}
# self.dimensions is a dict of {BaseDimension: index}
dimensions
=
base_units
.
keys
()
dimensions
=
sorted
(
base_units
.
keys
())
dimensions
.
sort
()
self
.
dimensions
=
{}
self
.
dimensions
=
{}
for
d
in
range
(
len
(
dimensions
)):
for
d
in
range
(
len
(
dimensions
)):
self
.
dimensions
[
dimensions
[
d
]]
=
d
self
.
dimensions
[
dimensions
[
d
]]
=
d
...
...
wrappers/python/tests/TestAmberPrmtopFile.py
View file @
b665dfcb
...
@@ -288,7 +288,7 @@ class TestAmberPrmtopFile(unittest.TestCase):
...
@@ -288,7 +288,7 @@ class TestAmberPrmtopFile(unittest.TestCase):
for
i
in
range
(
5
):
for
i
in
range
(
5
):
system
=
prmtop2
.
createSystem
(
implicitSolvent
=
solventType
[
i
],
nonbondedMethod
=
nonbondedMethod
[
i
],
implicitSolventSaltConc
=
salt
[
i
])
system
=
prmtop2
.
createSystem
(
implicitSolvent
=
solventType
[
i
],
nonbondedMethod
=
nonbondedMethod
[
i
],
implicitSolventSaltConc
=
salt
[
i
])
integrator
=
VerletIntegrator
(
0.001
)
integrator
=
VerletIntegrator
(
0.001
)
context
=
Context
(
system
,
integrator
,
Platform
.
getPlatformByName
(
"
CPU
"
))
context
=
Context
(
system
,
integrator
,
Platform
.
getPlatformByName
(
"
Reference
"
))
context
.
setPositions
(
pdb
.
positions
)
context
.
setPositions
(
pdb
.
positions
)
state1
=
context
.
getState
(
getForces
=
True
)
state1
=
context
.
getState
(
getForces
=
True
)
state2
=
XmlSerializer
.
deserialize
(
open
(
'systems/alanine-dipeptide-implicit-forces/'
+
file
[
i
]
+
'.xml'
).
read
())
state2
=
XmlSerializer
.
deserialize
(
open
(
'systems/alanine-dipeptide-implicit-forces/'
+
file
[
i
]
+
'.xml'
).
read
())
...
...
wrappers/python/tests/TestCharmmFiles.py
View file @
b665dfcb
...
@@ -131,7 +131,7 @@ class TestCharmmFiles(unittest.TestCase):
...
@@ -131,7 +131,7 @@ class TestCharmmFiles(unittest.TestCase):
for
i
in
range
(
5
):
for
i
in
range
(
5
):
system
=
self
.
psf_c
.
createSystem
(
self
.
params
,
implicitSolvent
=
solventType
[
i
],
nonbondedMethod
=
nonbondedMethod
[
i
],
implicitSolventSaltConc
=
salt
[
i
])
system
=
self
.
psf_c
.
createSystem
(
self
.
params
,
implicitSolvent
=
solventType
[
i
],
nonbondedMethod
=
nonbondedMethod
[
i
],
implicitSolventSaltConc
=
salt
[
i
])
integrator
=
VerletIntegrator
(
0.001
)
integrator
=
VerletIntegrator
(
0.001
)
context
=
Context
(
system
,
integrator
,
Platform
.
getPlatformByName
(
"
CPU
"
))
context
=
Context
(
system
,
integrator
,
Platform
.
getPlatformByName
(
"
Reference
"
))
context
.
setPositions
(
self
.
pdb
.
positions
)
context
.
setPositions
(
self
.
pdb
.
positions
)
state1
=
context
.
getState
(
getForces
=
True
)
state1
=
context
.
getState
(
getForces
=
True
)
#out = open('systems/ala-ala-ala-implicit-forces/'+file[i]+'.xml', 'w')
#out = open('systems/ala-ala-ala-implicit-forces/'+file[i]+'.xml', 'w')
...
...
Prev
1
2
3
Next
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