def test_jd_calendar(): # Check a specific instance (using UNIX epoch here, though that's # an arbitrary choice) jd_unix = 2440587.5 cal_unix = (1970, 1, 1, 0, 0, 0.0) cal = calendar_tuple(jd_unix) # Check that the returned value is correct assert cal == cal_unix # Check that all the return types are correct assert isinstance(cal[0], numbers.Integral) # Year assert isinstance(cal[1], numbers.Integral) # Month assert isinstance(cal[2], numbers.Integral) # Day assert isinstance(cal[3], numbers.Integral) # Hour assert isinstance(cal[4], numbers.Integral) # Minute assert isinstance(cal[5], numbers.Real) # Second # Check backward conversion assert julian_date(*cal) == jd_unix # Check array conversion components jd_array = jd_unix + np.arange(5.0) cal_array = calendar_tuple(jd_array) assert (cal_array[0] == 1970).all() assert (cal_array[1] == 1).all() assert (cal_array[2] == np.arange(1, 6)).all() assert (cal_array[3] == 0).all() assert (cal_array[4] == 0).all() assert (cal_array[5] == 0.0).all() # Check reversal of array assert (julian_date(*cal_array) == jd_array).all()
def test_jd_calendar(): import numbers # Check a specific instance (using UNIX epoch here, though that's # an arbitrary choice) jd_unix = 2440587.5 cal_unix = (1970, 1, 1, 0, 0, 0.0) cal = calendar_tuple(jd_unix) # Check that the returned value is correct assert cal == cal_unix # Check that all the return types are correct assert isinstance(cal[0], numbers.Integral) # Year assert isinstance(cal[1], numbers.Integral) # Month assert isinstance(cal[2], numbers.Integral) # Day assert isinstance(cal[3], numbers.Integral) # Hour assert isinstance(cal[4], numbers.Integral) # Minute assert isinstance(cal[5], numbers.Real) # Second # Check backward conversion assert julian_date(*cal) == jd_unix # Check array conversion components jd_array = jd_unix + np.arange(5.0) cal_array = calendar_tuple(jd_array) assert (cal_array[0] == 1970).all() assert (cal_array[1] == 1).all() assert (cal_array[2] == np.arange(1, 6)).all() assert (cal_array[3] == 0).all() assert (cal_array[4] == 0).all() assert (cal_array[5] == 0.0).all() # Check reversal of array assert (julian_date(*cal_array) == jd_array).all()