From cdae1a830fd5e25b359a64676317d63e6a59f390 Mon Sep 17 00:00:00 2001 From: Ardavan Oskooi Date: Thu, 26 Aug 2021 11:31:58 -0700 Subject: [PATCH] tweak relative tolerance of two failing unit tests for multithreading and single precision (#1742) --- python/tests/test_force.py | 4 +++- python/tests/test_holey_wvg_bands.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/python/tests/test_force.py b/python/tests/test_force.py index a2588de45..5a3078bb2 100644 --- a/python/tests/test_force.py +++ b/python/tests/test_force.py @@ -35,7 +35,9 @@ def test_force(self): f = mp.get_forces(self.myforce) self.assertAlmostEqual(f[0], -0.11039089113393187) - self.assertAlmostEqual(f[0], mp.get_forces(self.myforce_decimated)[0]) + + places = 6 if mp.is_single_precision() else 7 + self.assertAlmostEqual(f[0], mp.get_forces(self.myforce_decimated)[0], places=places) if __name__ == '__main__': diff --git a/python/tests/test_holey_wvg_bands.py b/python/tests/test_holey_wvg_bands.py index 6d8044a28..1e51bef6b 100644 --- a/python/tests/test_holey_wvg_bands.py +++ b/python/tests/test_holey_wvg_bands.py @@ -65,7 +65,7 @@ def test_fields_at_kx(self): ] self.assertTrue(h.modes) - places = 5 if mp.is_single_precision() else 7 + places = 4 if mp.is_single_precision() else 7 for (r, i), m in zip(expected, h.modes): self.assertAlmostEqual(m.freq, r, places=places) self.assertAlmostEqual(m.decay, i, places=places)