Пример #1
0
 def test_set_details(self):
     xyz = np.array([[1.0, 1.0]])
     vel = np.array([[2.0, 2.0]])
     snap = ExternalMDSnapshot(file_name='bar', file_position=0)
     snap.set_details(xyz=xyz, velocities=vel, box_vectors=self.box)
     np.testing.assert_array_equal(snap._xyz, xyz)
     np.testing.assert_array_equal(snap._velocities, vel)
     np.testing.assert_array_equal(snap._box_vectors, self.box)
Пример #2
0
 def test_load_details_indexerror(self):
     engine = ErrorMockEngine(self.engine.sequences)
     snap = ExternalMDSnapshot(file_name='foo',
                               file_position=0,
                               engine=engine)
     snap.load_details()
     np.testing.assert_array_equal(snap._xyz, np.array([[0.0, 0.0]]))
     np.testing.assert_array_equal(snap._velocities, self.vel)
     np.testing.assert_array_equal(snap._box_vectors, self.box)
Пример #3
0
    def setup(self):
        self.box = np.array([[1.0, 0.0], [0.0, 1.0]])
        self.vel = np.array([[1.0, 0.0]])

        self.engine = MockEngine(sequences={
            'foo': [(np.array([[0.0, 0.0]]), self.vel, self.box),
                    (np.array([[0.1, 0.0]]), self.vel, self.box),
                    (np.array([[0.2, 0.0]]), self.vel, self.box)]
        },
                                 sleep_ms=0.0)
        self.snapshots = [
            ExternalMDSnapshot(file_name='foo',
                               file_position=i,
                               engine=self.engine) for i in range(3)
        ]
Пример #4
0
 def test_load_details_recursionerror(self):
     bad_snap = ExternalMDSnapshot(file_name='foo',
                                   file_position=3,
                                   engine=self.engine)
     with pytest.raises(RuntimeError):
         bad_snap.load_details()