Пример #1
0
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)
Пример #2
0
def test_str_to_mjds_array(s):
    i, f = str_to_mjds(s)
    assert np.shape(i) == np.shape(f) == np.shape(s)
    for i_i, f_i, s_i in np.nditer([i, f, s], flags=["refs_ok"]):
        assert i_i, f_i == str_to_mjds(s_i)
Пример #3
0
def test_str_to_mjds_singleton_arrayobj():
    s = np.array(["41498.0"])[0]
    assert isinstance(s, str)
    jd1, jd2 = str_to_mjds(s)
    assert isinstance(jd1, float)
    assert isinstance(jd2, float)
Пример #4
0
def test_str_to_mjds_exponential_fortran():
    assert str_to_mjds("4.1498d4") == str_to_mjds("41498")
Пример #5
0
def test_str_to_mjds_exponential_negative():
    str_to_mjds("4.1498e-4")
Пример #6
0
def test_str_to_mjds_exponential():
    assert str_to_mjds("4.1498e4") == str_to_mjds("41498")
Пример #7
0
def test_str_to_mjds_singleton():
    jd1, jd2 = str_to_mjds("41498.0")
    assert isinstance(jd1, float)
    assert isinstance(jd2, float)
Пример #8
0
def test_mjds_to_str_array_roundtrip_doesnt_crash(sif):
    s, i, f = sif
    assume(s != ())
    str_to_mjds(mjds_to_str(i, f))
Пример #9
0
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
Пример #10
0
def test_str_to_mjds(dec, i_f):
    i, f = i_f
    assert_closer_than_ns(str_to_mjds(str(decimalify(i, f))), i_f, 1)
Пример #11
0
def test_str_to_mjds(i_f):
    i, f = i_f
    with decimal.localcontext(decimal.Context(prec=40)):
        assert_closer_than_ns(str_to_mjds(str(decimalify(i, f))), i_f, 1)