def test_add_atom(self): frame = Frame() frame.add_atom(Atom("F"), (3, 4, 5)) self.assertEqual(len(frame.atoms), 1) self.assertEqual(list(frame.positions[0]), [3, 4, 5]) frame.add_velocities() frame.add_atom(Atom("F"), (-3, -4, 5), (1, 0, 1)) self.assertEqual(list(frame.positions[1]), [-3, -4, 5]) self.assertEqual(list(frame.velocities[1]), [1, 0, 1])
def test_velocities(self): frame = Frame() frame.resize(4) self.assertFalse(frame.has_velocities()) frame.add_velocities() self.assertTrue(frame.has_velocities()) expected = np.array( [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0], [10.0, 11.0, 12.0]], np.float64, ) np.copyto(frame.velocities, expected) self.assertEqual(frame.velocities.all(), expected.all()) frame.velocities[3, 2] = 42 self.assertEqual(frame.velocities[3, 2], 42) # Checking empty frame velocities access frame = Frame() frame.add_velocities() _ = frame.velocities