def test_mjds_to_str_array(sif): s, i, f = sif r = mjds_to_str(i, f) assert hasattr(r, "dtype") assert np.shape(r) == s for r_i, i_i, f_i in np.nditer([r, i, f], flags=["refs_ok"]): assert r_i == mjds_to_str(i_i, f_i)
def test_mjds_to_str(i_f): i, f = i_f with decimal.localcontext(decimal.Context(prec=40)): s = mjds_to_str(i, f) d = Decimal(s) * 86400 * 10**9 d2 = decimalify(i, f) * 86400 * 10**9 assert abs(d2 - d) < 1
def test_mjds_to_str_array_roundtrip_close(sif): s, i, f = sif i_o, f_o = str_to_mjds(mjds_to_str(i, f)) assert hasattr(i_o, "dtype") assert hasattr(f_o, "dtype") l = i.astype(np.longdouble) + f.astype(np.longdouble) l_o = i_o.astype(np.longdouble) + f_o.astype(np.longdouble) assert np.all(np.abs(l - l_o) * 86400 < 1e-9)
def test_mjds_to_str_singleton(): assert isinstance(mjds_to_str(40000, 0.0), (str, bytes))
def test_mjds_to_str_array_roundtrip_doesnt_crash(sif): s, i, f = sif assume(s != ()) str_to_mjds(mjds_to_str(i, f))
def mjd_strs(draw): i = draw(integers(min_value=40000, max_value=60000)) f = draw(floats(0, 1, allow_nan=False)) return mjds_to_str(i, f)
def test_mjds_to_str_singleton(): assert isinstance(mjds_to_str(40000, 0.0), six.string_types)
def test_mjds_to_str_roundtrip(i_f): i, f = i_f d = (decimalify(i, f) * u.day).to(u.ns) i_o, f_o = str_to_mjds(mjds_to_str(i, f)) d_o = (decimalify(i_o, f_o) * u.day).to(u.ns) assert abs(d_o - d) < time_eps
def test_mjds_to_str(dec, i_f): i, f = i_f s = mjds_to_str(i, f) d = Decimal(s) * 86400 * 10 ** 9 d2 = decimalify(i, f) * 86400 * 10 ** 9 assert abs(d2 - d) < 1
def mjd_strs(draw): i = draw(integers(40000, 70000)) f = draw(floats(0, 1, allow_nan=False)) return mjds_to_str(i, f)