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
3cc6a186
Commit
3cc6a186
authored
Jul 05, 2016
by
peastman
Committed by
GitHub
Jul 05, 2016
Browse files
Merge pull request #1536 from peastman/filewarning
Eliminated warnings about unclosed files
parents
c3d1e8a4
258ef062
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
62 deletions
+63
-62
wrappers/python/simtk/openmm/app/charmmcrdfiles.py
wrappers/python/simtk/openmm/app/charmmcrdfiles.py
+44
-44
wrappers/python/simtk/openmm/app/charmmpsffile.py
wrappers/python/simtk/openmm/app/charmmpsffile.py
+17
-17
wrappers/python/tests/TestCharmmFiles.py
wrappers/python/tests/TestCharmmFiles.py
+2
-1
No files found.
wrappers/python/simtk/openmm/app/charmmcrdfiles.py
View file @
3cc6a186
...
...
@@ -81,7 +81,7 @@ class CharmmCrdFile(object):
def
_parse
(
self
,
fname
):
crdfile
=
open
(
fname
,
'r'
)
with
open
(
fname
,
'r'
)
as
crdfile
:
line
=
crdfile
.
readline
()
while
len
(
line
.
strip
())
==
0
:
# Skip whitespace, as a precaution
...
...
wrappers/python/simtk/openmm/app/charmmpsffile.py
View file @
3cc6a186
...
...
@@ -178,7 +178,7 @@ class CharmmPsfFile(object):
if
not
os
.
path
.
exists
(
psf_name
):
raise
IOError
(
'Could not find PSF file %s'
%
psf_name
)
# Open the PSF and read the first line. It must start with "PSF"
psf
=
open
(
psf_name
,
'r'
)
with
open
(
psf_name
,
'r'
)
as
psf
:
line
=
psf
.
readline
()
if
not
line
.
startswith
(
'PSF'
):
raise
CharmmPSFError
(
'Unrecognized PSF file. First line is %s'
%
...
...
wrappers/python/tests/TestCharmmFiles.py
View file @
3cc6a186
...
...
@@ -165,7 +165,8 @@ class TestCharmmFiles(unittest.TestCase):
#out = open('systems/ala-ala-ala-implicit-forces/'+file[i]+'.xml', 'w')
#out.write(XmlSerializer.serialize(state1))
#out.close()
state2
=
XmlSerializer
.
deserialize
(
open
(
'systems/ala-ala-ala-implicit-forces/'
+
file
[
i
]
+
'.xml'
).
read
())
with
open
(
'systems/ala-ala-ala-implicit-forces/'
+
file
[
i
]
+
'.xml'
)
as
xml
:
state2
=
XmlSerializer
.
deserialize
(
xml
.
read
())
for
f1
,
f2
,
in
zip
(
state1
.
getForces
().
value_in_unit
(
kilojoules_per_mole
/
nanometer
),
state2
.
getForces
().
value_in_unit
(
kilojoules_per_mole
/
nanometer
)):
diff
=
norm
(
f1
-
f2
)
self
.
assertTrue
(
diff
<
0.1
or
diff
/
norm
(
f1
)
<
1e-4
)
...
...
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