Commit 174b57e4 authored by tic20's avatar tic20
Browse files

Revert "Ensuring opened files are closed properly when done"

This reverts commit 5ef91d22.
parent 5ef91d22
...@@ -133,8 +133,7 @@ class GromacsGroFile(object): ...@@ -133,8 +133,7 @@ class GromacsGroFile(object):
xyz = [] xyz = []
ln = 0 ln = 0
frame = 0 frame = 0
with open(file) as grofile: for line in open(file):
for line in grofile:
if ln == 0: if ln == 0:
comms.append(line.strip()) comms.append(line.strip())
elif ln == 1: elif ln == 1:
......
...@@ -75,7 +75,6 @@ class PDBxFile(object): ...@@ -75,7 +75,6 @@ class PDBxFile(object):
reader = PdbxReader(inputFile) reader = PdbxReader(inputFile)
data = [] data = []
reader.read(data) reader.read(data)
inputfile.close()
block = data[0] block = data[0]
# Build the topology. # Build the topology.
......
...@@ -293,8 +293,7 @@ class TestAmberPrmtopFile(unittest.TestCase): ...@@ -293,8 +293,7 @@ class TestAmberPrmtopFile(unittest.TestCase):
context = Context(system, integrator, Platform.getPlatformByName("Reference")) 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)
with open('systems/alanine-dipeptide-implicit-forces/'+file[i]+'.xml') as infile: state2 = XmlSerializer.deserialize(open('systems/alanine-dipeptide-implicit-forces/'+file[i]+'.xml').read())
state2 = XmlSerializer.deserialize(infile.read())
for f1, f2, in zip(state1.getForces().value_in_unit(kilojoules_per_mole/nanometer), state2.getForces().value_in_unit(kilojoules_per_mole/nanometer)): 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) diff = norm(f1-f2)
self.assertTrue(diff < 0.1 or diff/norm(f1) < 1e-4) self.assertTrue(diff < 0.1 or diff/norm(f1) < 1e-4)
......
...@@ -67,8 +67,7 @@ class TestPdbFile(unittest.TestCase): ...@@ -67,8 +67,7 @@ class TestPdbFile(unittest.TestCase):
def test_BinaryStream(self): def test_BinaryStream(self):
"""Test reading a stream that was opened in binary mode.""" """Test reading a stream that was opened in binary mode."""
with open('systems/triclinic.pdb', 'rb') as infile: pdb = PDBFile(open('systems/triclinic.pdb', 'rb'))
pdb = PDBFile(infile)
self.assertEqual(len(pdb.positions), 8) self.assertEqual(len(pdb.positions), 8)
def test_ExtraParticles(self): def test_ExtraParticles(self):
......
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