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
c66e086e
Commit
c66e086e
authored
Jan 12, 2015
by
peastman
Browse files
Merge pull request #773 from rmcgibbo/bytes-2
stripUnits behavior with bytes
parents
85494077
e197379c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
25 deletions
+9
-25
wrappers/python/src/swig_doxygen/swig_lib/python/pythoncode.i
...pers/python/src/swig_doxygen/swig_lib/python/pythoncode.i
+9
-25
No files found.
wrappers/python/src/swig_doxygen/swig_lib/python/pythoncode.i
View file @
c66e086e
...
@@ -9,6 +9,10 @@ import sys
...
@@ -9,6 +9,10 @@ import sys
import
math
import
math
RMIN_PER_SIGMA
=
math
.
pow
(
2
,
1
/
6.0
)
RMIN_PER_SIGMA
=
math
.
pow
(
2
,
1
/
6.0
)
RVDW_PER_SIGMA
=
math
.
pow
(
2
,
1
/
6.0
)
/
2.0
RVDW_PER_SIGMA
=
math
.
pow
(
2
,
1
/
6.0
)
/
2.0
if
sys
.
version_info
[
0
]
==
2
:
_string_types
=
(
basestring
,)
else
:
_string_types
=
(
bytes
,
str
)
import
simtk
.
unit
as
unit
import
simtk
.
unit
as
unit
from
simtk
.
openmm
.
vec3
import
Vec3
from
simtk
.
openmm
.
vec3
import
Vec3
...
@@ -215,25 +219,6 @@ class State(_object):
...
@@ -215,25 +219,6 @@ class State(_object):
return
self
.
_paramMap
return
self
.
_paramMap
#
Strings
can
cause
trouble
#
as
can
any
container
that
has
infinite
levels
of
containment
def
_is_string
(
x
)
:
#
step
1
)
String
is
always
a
container
#
and
its
contents
are
themselves
containers
.
try
:
first_item
=
iter
(
x
)
.
next
()
inner_item
=
iter
(
first_item
)
.
next
()
if
first_item
==
inner_item
:
return
True
else
:
return
False
except
TypeError
:
return
False
except
StopIteration
:
return
False
except
ValueError
:
return
False
def
stripUnits
(
args
)
:
def
stripUnits
(
args
)
:
"""
"""
getState(self, quantity)
getState(self, quantity)
...
@@ -282,15 +267,14 @@ def stripUnits(args):
...
@@ -282,15 +267,14 @@ def stripUnits(args):
if
arg
.
unit
.
is_compatible
(
unit
.
bar
)
:
if
arg
.
unit
.
is_compatible
(
unit
.
bar
)
:
arg
=
arg
/
unit
.
bar
arg
=
arg
/
unit
.
bar
else
:
else
:
arg
=
arg
.
value_in_unit_system
(
unit
.
md_unit_system
)
arg
=
arg
.
value_in_unit_system
(
unit
.
md_unit_system
)
#
JDC
:
End
workaround
.
#
JDC
:
End
workaround
.
elif
isinstance
(
arg
,
dict
)
:
elif
isinstance
(
arg
,
dict
)
:
newKeys
=
stripUnits
(
arg
.
keys
())
newKeys
=
stripUnits
(
arg
.
keys
())
newValues
=
stripUnits
(
arg
.
values
())
newValues
=
stripUnits
(
arg
.
values
())
arg
=
dict
(
zip
(
newKeys
,
newValues
))
arg
=
dict
(
zip
(
newKeys
,
newValues
))
elif
not
_
is_string
(
arg
)
:
elif
not
is
instance
(
arg
,
_string
_types
)
:
try
:
try
:
iter
(
arg
)
#
Reclusively
strip
units
from
all
quantities
#
Reclusively
strip
units
from
all
quantities
arg
=
stripUnits
(
arg
)
arg
=
stripUnits
(
arg
)
except
TypeError
:
except
TypeError
:
...
...
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