Skip to content

Commit

Permalink
test_ca43_consts: Fix comparison accuracy
Browse files Browse the repository at this point in the history
`places` is the absolute power-of-ten delta allowed, not the number
of significant figures.
  • Loading branch information
dnadlinger committed Nov 1, 2023
1 parent 5b44aaa commit e810a4c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions atomic_physics/tests/test_ca43_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@ def test_s12_d52_clock(self):
ion, l_index, u_index, B0=S12_44_D52_43_clock_fields[0]
)
self.assertAlmostEqual(
model_field_independent_point_1, S12_44_D52_43_clock_fields[0], places=2
model_field_independent_point_1, S12_44_D52_43_clock_fields[0], places=6
)

# 4.96 G
# The curve is quite flat near this point, giving the solver some trouble. Using a slightly larger delta
model_field_independent_point_2 = field_insensitive_point(
ion, l_index, u_index, B0=S12_44_D52_43_clock_fields[1]
)
# FIXME: field_insensitive_point() gives 4.947… G, which does not match the
# value from [1] to the number of significant digits given there. This is not a
# straightforward root finding or finite-difference accuracy issue.
self.assertAlmostEqual(
model_field_independent_point_2, S12_44_D52_43_clock_fields[1], delta=0.02
model_field_independent_point_2, S12_44_D52_43_clock_fields[1], places=5
)

def test_s12_40_31_clock(self):
Expand All @@ -55,8 +57,10 @@ def test_s12_40_31_clock(self):
model_field_independent_point_40_31 = field_insensitive_point(
ion, s12_40_index, s12_31_index, B0=S12_40_31_clock_field
)
# FIXME: field_insensitive_point() gives 146.089 G, which does not match the
# value from [2] (see GitHub issue #24); fix and increase `places` to 7.
self.assertAlmostEqual(
model_field_independent_point_40_31, S12_40_31_clock_field, places=1
model_field_independent_point_40_31, S12_40_31_clock_field, places=6
)

def test_s12_41_31_clock(self):
Expand All @@ -71,5 +75,5 @@ def test_s12_41_31_clock(self):
ion, s12_41_index, s12_31_index, B0=S12_41_31_clock_field
)
self.assertAlmostEqual(
model_field_independent_point_41_31, S12_41_31_clock_field, delta=1
model_field_independent_point_41_31, S12_41_31_clock_field, places=4
)

0 comments on commit e810a4c

Please sign in to comment.