"...ssh:/git@developer.sourcefind.cn:2222/tsoc/openmm.git" did not exist on "bf6d95c2abc400d1af2e508b26aeb913a1fbc00b"
Commit 90dfedb8 authored by Jason Swails's avatar Jason Swails
Browse files

Remove a context manager to improve compatibility with older versions of scipy.

parent efc196e1
...@@ -1179,7 +1179,8 @@ class AmberNetcdfRestart(object): ...@@ -1179,7 +1179,8 @@ class AmberNetcdfRestart(object):
# open. This is unnecessary in scipy v.0.12 and lower because NetCDFFile # open. This is unnecessary in scipy v.0.12 and lower because NetCDFFile
# accidentally leaks the file handle, but that was 'fixed' in 0.13. This # accidentally leaks the file handle, but that was 'fixed' in 0.13. This
# fix taken from MDTraj # fix taken from MDTraj
with NetCDFFile(filename, 'r') as ncfile: ncfile = NetCDFFile(filename, 'r')
try:
self.natom = ncfile.dimensions['atom'] self.natom = ncfile.dimensions['atom']
self.coordinates = np.array(ncfile.variables['coordinates'][:]) self.coordinates = np.array(ncfile.variables['coordinates'][:])
if 'velocities' in ncfile.variables: if 'velocities' in ncfile.variables:
...@@ -1195,6 +1196,8 @@ class AmberNetcdfRestart(object): ...@@ -1195,6 +1196,8 @@ class AmberNetcdfRestart(object):
) )
if 'time' in ncfile.variables: if 'time' in ncfile.variables:
self.time = ncfile.variables['time'].getValue() self.time = ncfile.variables['time'].getValue()
finally:
ncfile.close()
# They are already numpy -- convert to list if we don't want numpy # They are already numpy -- convert to list if we don't want numpy
if not asNumpy: if not asNumpy:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment