Skip to content

Commit 1b9af23

Browse files
committed
Indicate problem with MJD initialization
Demonstrates astropy#9327
1 parent 1a11bea commit 1b9af23

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎astropy/time/tests/test_precision.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import pytest
44
import numpy as np
55

6+
import astropy.units as u
7+
import astropy._erfa as erfa
68
from astropy.time import Time, TimeDelta
9+
from astropy.time.utils import day_frac
710
from astropy.utils import iers
811

912
allclose_jd = functools.partial(np.allclose, rtol=2. ** -52, atol=0)
@@ -133,3 +136,11 @@ def test_leap_seconds_rounded_correctly():
133136
assert np.all(t.iso == np.array(['2012-06-30 23:59:60.000',
134137
'2012-07-01 00:00:00.000']))
135138
# with the bug, both yielded '2012-06-30 23:59:60.000'
139+
140+
141+
def test_mjd_initialization_precise():
142+
i, f = 65536, 3.637978807091714e-12 # Found using hypothesis
143+
t = Time(val=i, val2=f, format="mjd", scale="tai")
144+
jd1, jd2 = day_frac(i + erfa.DJM0, f)
145+
jd1_t, jd2_t = day_frac(t.jd1, t.jd2)
146+
assert (abs((jd1-jd1_t) + (jd2-jd2_t))*u.day).to(u.ns) < 1*u.ns

0 commit comments

Comments
 (0)