def test_time_to_mjd_string_format_dependence(i, f): t = Time(val=i, val2=f, format="mjd", scale="tai") t2 = Time(val=i, val2=f, format="pulsar_mjd", scale="tai") assert_quantity_allclose( np.longdouble(time_to_mjd_string(t)) * u.day, np.longdouble(time_to_mjd_string(t2)) * u.day, rtol=0, atol=1.0 * u.ns, )
def test_time_to_longdouble_close_to_time_to_mjd_string(format, i, f): t = Time(val=i, val2=f, format=format, scale="tai") assert_quantity_allclose( np.longdouble(time_to_mjd_string(t)) * u.day, time_to_longdouble(t) * u.day, rtol=0, atol=3.0 * u.ns, )
def test_time_to_mjd_string_precision(format, i, f): t = Time(val=i, val2=f, format=format, scale="tai") ld = np.longdouble(i) + np.longdouble(f) assert_quantity_allclose( np.longdouble(time_to_mjd_string(t)) * u.day, ld * u.day, rtol=0, atol=2.0 * u.ns, )
def test_time_from_mjd_string_roundtrip_very_close(i, f): i = 50000 f = np.finfo(float).eps t = Time(val=i, val2=f, format="pulsar_mjd", scale="utc") s = time_to_mjd_string(t) assert abs(time_from_mjd_string(s) - t).to(u.ns) <= 4 * time_eps
def test_time_to_longdouble_no_longer_than_time_to_mjd_string(i, f): t = Time(val=i, val2=f, format="mjd", scale="tai") assert len(time_to_mjd_string(t)) >= len(str(time_to_longdouble(t)))