Skip to content

Commit

Permalink
More (better?) handling of order of magnitudes in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bonfus committed Feb 24, 2018
1 parent 69570ea commit 807da3f
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions muesr/tests/test_muesr.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,12 @@ def test_compare_ass_and_rass(self):
r2[0].ACont = 1.0
r1[1].ACont = 1.0
r2[1].ACont = 1.0
np.testing.assert_array_almost_equal(r1[0].T,r2[0].T[0],decimal=5)
np.testing.assert_array_almost_equal(r1[1].T,r2[1].T[0],decimal=5)

min_oom = min(self.oom(r1[0].T), self.oom(r2[0].T[0]))
np.testing.assert_array_almost_equal(r1[0].T,r2[0].T[0],decimal=6-min_oom)

min_oom = min(self.oom(r1[1].T), self.oom(r2[1].T[0]))
np.testing.assert_array_almost_equal(r1[1].T,r2[1].T[0],decimal=6-min_oom)

def test_compare_rass_and_incass(self):
m = Sample()
Expand Down Expand Up @@ -258,20 +262,28 @@ def test_compare_rass_and_incass(self):
r2[1].ACont = 1.0
r3[1].ACont = 1.0

np.testing.assert_array_almost_equal(r1[0].T,r2[0].T[0],decimal=7-self.oom(r2[0].T[0]))
np.testing.assert_array_almost_equal(r1[1].T,r2[1].T[0],decimal=7-self.oom(r2[1].T[0]))
min_oom = min(self.oom(r1[0].T), self.oom(r2[0].T[0]))
np.testing.assert_array_almost_equal(r1[0].T,r2[0].T[0],decimal=7-min_oom)
min_oom = min(self.oom(r1[1].T), self.oom(r2[1].T[0]))
np.testing.assert_array_almost_equal(r1[1].T,r2[1].T[0],decimal=7-min_oom)

r2_norms = np.apply_along_axis(np.linalg.norm, 1, r2[0].D)
r3_norms = np.apply_along_axis(np.linalg.norm, 1, r3[0].D)

np.testing.assert_array_almost_equal(np.max(r2_norms),np.max(r3_norms),decimal=4-self.oom(r2_norms))
np.testing.assert_array_almost_equal(np.min(r2_norms),np.min(r3_norms),decimal=4-self.oom(r2_norms))
min_oom=min(self.oom(np.max(r2_norms)), self.oom(np.max(r3_norms)))
np.testing.assert_array_almost_equal(np.max(r2_norms),np.max(r3_norms),decimal=4-min_oom)

min_oom=min(self.oom(np.min(r2_norms)), self.oom(np.min(r3_norms)))
np.testing.assert_array_almost_equal(np.min(r2_norms),np.min(r3_norms),decimal=4-min_oom)

r2_norms = np.apply_along_axis(np.linalg.norm, 1, r2[1].T)
r3_norms = np.apply_along_axis(np.linalg.norm, 1, r3[1].T)

np.testing.assert_array_almost_equal(np.max(r2_norms),np.max(r2_norms),decimal=5)
np.testing.assert_array_almost_equal(np.min(r3_norms),np.min(r3_norms),decimal=5)
min_oom=min(self.oom(np.max(r2_norms)), self.oom(np.max(r3_norms)))
np.testing.assert_array_almost_equal(np.max(r2_norms),np.max(r2_norms),decimal=5-min_oom)

min_oom=min(self.oom(np.min(r2_norms)), self.oom(np.min(r3_norms)))
np.testing.assert_array_almost_equal(np.min(r3_norms),np.min(r3_norms),decimal=5-min_oom)


def test_magmodel_input(self):
Expand Down

0 comments on commit 807da3f

Please sign in to comment.