From 1d0860e0a928aa80c774bcba044cf7b7d33129f3 Mon Sep 17 00:00:00 2001
From: nguyed99 <nguyed99@zedat.fu-berlin.de>
Date: Mon, 29 Jan 2024 17:32:13 +0100
Subject: [PATCH] correct unit test yoohoo!

---
 jobs/tests/test_integrator.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/jobs/tests/test_integrator.py b/jobs/tests/test_integrator.py
index 3192c19..ad4b9e1 100644
--- a/jobs/tests/test_integrator.py
+++ b/jobs/tests/test_integrator.py
@@ -67,7 +67,7 @@ class IntegratorTest(unittest.TestCase):
         """
 
         system = GravitationalSystem(r0=x0[:4],
-                                     v0=x0[:4],
+                                     v0=x0[4:],
                                      m=np.array([M_E, M_E, M_L, M_L]),
                                      t=np.linspace(0, T, int(T // dt)),
                                      force=force,
@@ -79,13 +79,13 @@ class IntegratorTest(unittest.TestCase):
         H = np.linalg.norm(p[:,:2], axis=1)**2 / (2 * M_E) + np.linalg.norm(p[:,2:], axis=1)**2 / (2 * M_L) + \
             -G * M_S * M_E / np.linalg.norm(q[:,:2], axis=1) - G * M_S * M_L / np.linalg.norm(q[:,2:], axis=1) + \
             -G * M_E * M_L / np.linalg.norm(q[:,2:] - q[:,:2], axis=1)
-        self.assertTrue(np.greater(1e-2 + np.zeros(H.shape[0]),
-                                   H - H[0]).all())  #TODO: why is it so badly conserved..., DEBUG another day...
+
+        self.assertTrue(np.greater(1e-10 + np.zeros(H.shape[0]), H - H[0]).all())
 
         ## checking total momentum conservation
-        L = np.cross(q[:, :2], p[:, :2]) + np.cross(q[:, 2:], p[:,
-                                                                2:])  # TODO: strange behaviour..., DEBUG another day...
-        self.assertTrue(np.array_equal(np.zeros(L.shape[0]), L))
+        L = np.cross(q[:, :2], p[:, :2]) + np.cross(q[:, 2:], p[:, 2:])
+
+        self.assertTrue(np.greater(1e-10 + np.zeros(L.shape[0]), L - L[0]).all())
 
 
 if __name__ == '__main__':
-- 
GitLab