diff --git a/tests/test_fakepulsar.py b/tests/test_fakepulsar.py index 74091a6..b7a2928 100644 --- a/tests/test_fakepulsar.py +++ b/tests/test_fakepulsar.py @@ -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" @@ -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): """ @@ -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): """ diff --git a/tests/test_pulsar.py b/tests/test_pulsar.py index 63697bf..41ccd74 100644 --- a/tests/test_pulsar.py +++ b/tests/test_pulsar.py @@ -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 @@ -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))