Skip to content

Commit

Permalink
tests: set long double type to np.double for ARM64
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpitkin committed Jul 2, 2024
1 parent e09d4ea commit c127a45
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
11 changes: 8 additions & 3 deletions tests/test_fakepulsar.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@
TMP_DIR = Path("test_fake_output")
TMP_DIR.mkdir(exist_ok=True)

try:
NP_LONG_DOUBLE_TYPE = np.float128
except AttributeError:
NP_LONG_DOUBLE_TYPE = np.double


class TestFakePulsar(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.obstimes = np.arange(53000, 54800, 10, dtype=np.float128)
cls.obstimes = np.arange(53000, 54800, 10, dtype=NP_LONG_DOUBLE_TYPE)
cls.toaerr = 1e-3
cls.freq = 1440.0
cls.observatory = "ao"
Expand Down Expand Up @@ -133,7 +138,7 @@ def test_astropy_array(self):
self.assertEqual(len(self.obstimes), psr.nobs)
self.assertTrue(np.all(self.obstimes == self.fakepsr.stoas))
self.assertTrue(np.all(psr.stoas == self.fakepsr.stoas))
self.assertEqual(psr.stoas[0].dtype, np.float128)
self.assertEqual(psr.stoas[0].dtype, NP_LONG_DOUBLE_TYPE)

def test_single_values(self):
"""
Expand All @@ -151,7 +156,7 @@ def test_single_values(self):
self.assertEqual(psr.nobs, 1)
self.assertEqual(len(psr.stoas), 1)
self.assertTrue(np.all(self.fakepsr.stoas[0] == psr.stoas[0]))
self.assertEqual(psr.stoas[0].dtype, np.float128)
self.assertEqual(psr.stoas[0].dtype, NP_LONG_DOUBLE_TYPE)

def test_toa_errs(self):
"""
Expand Down
7 changes: 6 additions & 1 deletion tests/test_pulsar.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
TMP_DIR = Path("test_output")
TMP_DIR.mkdir(exist_ok=True)

try:
NP_LONG_DOUBLE_TYPE = np.float128
except AttributeError:
NP_LONG_DOUBLE_TYPE = np.double


class TestDeterministicSignals(unittest.TestCase):
@classmethod
Expand All @@ -29,7 +34,7 @@ def test_attrs(self):
self.assertTrue(np.all(self.psr.stoas > 50000) and np.all(self.psr.stoas < 59000))
self.assertTrue(np.all(self.psr.toaerrs > 0.01) and np.all(self.psr.toaerrs < 10))
self.assertTrue(np.all(self.psr.freqs > 700) and np.all(self.psr.freqs < 4000))
self.assertEqual(self.psr.stoas[0].dtype, np.float128)
self.assertEqual(self.psr.stoas[0].dtype, NP_LONG_DOUBLE_TYPE)

def test_toas(self):
self.assertTrue(np.all(self.psr.toas() != self.psr.stoas))
Expand Down

0 comments on commit c127a45

Please sign in to comment.