def test_mjds_to_jds_array(sif): s, i, f = sif jd1, jd2 = mjds_to_jds(i, f) assert np.shape(jd1) == np.shape(jd2) == s for jd1_i, jd2_i, i_i, f_i in np.nditer([jd1, jd2, i, f]): assert jd1_i, jd2_i == mjds_to_jds(i_i, f_i)
def test_mjds_to_jds_singleton(): jd1, jd2 = mjds_to_jds(40000, 0.0) assert isinstance(jd1, float) assert isinstance(jd2, float)
def test_mjd_jd_round_trip(dec, i_f): assert_closer_than_ns(jds_to_mjds(*mjds_to_jds(*i_f)), i_f, 1)
def test_jds_to_mjds_pulsar_raises_during_leap_second(): i = 41498 f = 86400.5 / 86401 jd1, jd2 = mjds_to_jds(i, f) with pytest.raises(ValueError): jds_to_mjds_pulsar(jd1, jd2)
def test_mjd_jd_round_trip(i_f): with decimal.localcontext(decimal.Context(prec=40)): assert_closer_than_ns(jds_to_mjds(*mjds_to_jds(*i_f)), i_f, 1)