def test_drift(self): soe1 = np.arange(2000000000., 2000000001., DRIFT_INTERVAL) seconds1, fraction1 = util.time_soe_to_int(soe1) soe2 = util.time_int_to_soe(seconds1, fraction1) seconds2, fraction2 = util.time_soe_to_int(soe2) np.testing.assert_equal(seconds1, seconds2) np.testing.assert_equal(fraction1, fraction2) delta = np.absolute(soe1 - soe2) self.assertLessEqual(delta.max(), 8e-07)
def test_numpy(self): soe = np.array([100.01, 200.015, 300.02]) seconds, fraction = util.time_soe_to_int(soe) exp_sec = np.array([100, 200, 300]) exp_fra = np.array([6250, 9375, 12500]) np.testing.assert_equal(seconds, exp_sec) np.testing.assert_equal(fraction, exp_fra)
def test_both(self): seconds, fraction = util.time_soe_to_int(24680.1) self.assertEqual(seconds, 24680) self.assertEqual(fraction, 62500)
def test_fraction(self): seconds, fraction = util.time_soe_to_int(0.5) self.assertEqual(seconds, 0) self.assertEqual(fraction, 312500)
def test_seconds(self): seconds, fraction = util.time_soe_to_int(123456789.) self.assertEqual(seconds, 123456789) self.assertEqual(fraction, 0)
def test_zero(self): seconds, fraction = util.time_soe_to_int(0.) self.assertEqual(seconds, 0) self.assertEqual(fraction, 0)
def test_sanity(self): util.time_soe_to_int(0.)