Commits

trikitrok committed 1cad6ca

refactored regression test for a short complete simulation

Comments (0)

Files changed (1)

tests/test_edmd.py

     box_size = 10
     sim = edmd.create_simulation(num_particles, seed, radius, box_size, eps, minimium_velocity, maximum_velocity)
     sim.run(10)
-    assert(np.all(np.loadtxt("tests/data/coords_regression.txt") == [particle.x for particle in sim.particles]))
-    assert(np.all(np.loadtxt("tests/data/vels_regression.txt") == [particle.v for particle in sim.particles]))
-    assert(np.all(np.loadtxt("tests/data/t_events_regression.txt") == sim.t_events))
+    tol = 1.0e-8
+    expected_coords = np.loadtxt("tests/data/coords_regression.txt")
+    expected_vels = np.loadtxt("tests/data/vels_regression.txt")
+    expected_t_events = np.loadtxt("tests/data/t_events_regression.txt")
+    assert(np.all( np.abs(expected_coords - [particle.x for particle in sim.particles] ) < tol))
+    assert(np.all( np.abs(expected_vels - [particle.v for particle in sim.particles] ) < tol))
+    assert(np.all( np.abs(expected_t_events - sim.t_events) < tol ) )