Skip to content

Commit

Permalink
adjust test assert threshholds for gon2dec() and hp2rad()
Browse files Browse the repository at this point in the history
  • Loading branch information
philanderson71 committed Nov 24, 2024
1 parent 98fb974 commit c9039c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions geodepy/angles.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,7 @@ def hp2dec(hp):
if int(hp_mmss_str[2]) > 5:
raise ValueError(f'Invalid HP Notation: 3rd decimal place greater '
f'than 5: {hp}')
# parse string to avoid precision problems with floating point ops and base 10 numbers
deg = abs(int(hp_deg_str))
min = int(hp_mmss_str[:2])
sec = float(hp_mmss_str[2:4] + '.' + hp_mmss_str[4:])
Expand Down
12 changes: 6 additions & 6 deletions geodepy/tests/test_angles.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,12 @@ def test_hp2gona(self):

def test_hp2rad(self):
for num, ex in enumerate(hp_exs):
self.assertEqual(hp2rad(ex), rad_exs[num])
self.assertEqual(hp2rad(-ex), -rad_exs[num])
self.assertAlmostEqual(hp2rad(ex), rad_exs[num], 15)
self.assertAlmostEqual(hp2rad(-ex), -rad_exs[num], 15)
for check in self.testData:
hp, dec, gon, rad = check
self.assertAlmostEqual(rad, hp2rad(hp), 13)
self.assertAlmostEqual(-rad, hp2rad(-hp), 13)
self.assertAlmostEqual(rad, hp2rad(hp), 15)
self.assertAlmostEqual(-rad, hp2rad(-hp), 15)

def test_hp2dms(self):
self.assertEqual(dms_ex.degree, hp2dms(hp_ex).degree)
Expand All @@ -603,8 +603,8 @@ def test_gon2dec(self):
self.assertAlmostEqual(gon2dec(-ex), -dec_exs[num], 14)
for check in self.testData:
hp, dec, gon, rad = check
self.assertAlmostEqual(dec, gon2dec(gon), 13)
self.assertAlmostEqual(-dec, gon2dec(-gon), 13)
self.assertAlmostEqual(dec, gon2dec(gon), delta = 5.8e-14)
self.assertAlmostEqual(-dec, gon2dec(-gon), delta = 5.8e-14)

def test_gon2deca(self):
for num, ex in enumerate(gon_exs):
Expand Down

0 comments on commit c9039c6

Please sign in to comment.