Skip to content

Fix jd1 and jd2 format - #6653

Merged
mhvk merged 7 commits into
astropy:masterfrom
astrojuanlu:fix-day-frac
Nov 6, 2017
Merged

mhvk merged 7 commits into
astropy:masterfrom
astrojuanlu:fix-day-frac

Conversation

@astrojuanlu

Copy link
Copy Markdown
Member

This is an attempt to fix #6638. However, as it can be seen in the last commit I didn't fix the original issue: this is because having the same order of magnitude is not enough to achieve perfect precision.

On the other hand, as advised by @mhvk I tried to do self.jd1, self.jd2 = day_frac(jd1, jd2) for TimeString as well, but several things broke. With this diff:

diff --git a/astropy/time/formats.py b/astropy/time/formats.py
index a0eee16..b496c4e 100644
--- a/astropy/time/formats.py
+++ b/astropy/time/formats.py
@@ -743,8 +743,9 @@ class TimeString(TimeUnique):
             iy[...], im[...], id[...], ihr[...], imin[...], dsec[...] = (
                 self.parse_string(val.item(), subfmts))
 
-        self.jd1, self.jd2 = erfa.dtf2d(self.scale.upper().encode('ascii'),
-                                        *iterator.operands[1:])
+        jd1, jd2 = erfa.dtf2d(self.scale.upper().encode('ascii'),
+                              *iterator.operands[1:])
+        self.jd1, self.jd2 = day_frac(jd1, jd2)
 
     def str_kwargs(self):
         """

I got several test failures, and the thing is that I am not sure what do do next.

Details
$ pytest astropy/time/tests/ -vInternet access disabled
/home/juanlu/.miniconda36/envs/astropy36_dev/lib/python3.6/importlib/_bootstrap.py:205: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
  return f(*args, **kwds)
================================== test session starts ==================================
platform linux -- Python 3.6.2, pytest-3.2.2, py-1.4.34, pluggy-0.4.0 -- /home/juanlu/.miniconda36/envs/astropy36_dev/bin/python
cachedir: .

Running tests with Astropy version 3.0.dev20237.
Running tests in astropy/time/tests/.

Date: 2017-10-04T01:00:14

Platform: Linux-4.10.0-35-generic-x86_64-with-debian-stretch-sid

Executable: /home/juanlu/.miniconda36/envs/astropy36_dev/bin/python

Full Python Version: 
3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:51:32) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]

encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8
byteorder: little
float info: dig: 15, mant_dig: 15

Numpy: 1.13.3
Scipy: 0.19.1
Matplotlib: not available
h5py: not available
Pandas: not available
Cython: 0.27.1
Using Astropy options: remote_data: none.

rootdir: /home/juanlu/Development/astropy, inifile: setup.cfg
plugins: cov-2.5.1
collected 251 items                                                                      

astropy/time/tests/test_basic.py::TestBasic::test_simple FAILED
astropy/time/tests/test_basic.py::TestBasic::test_different_dimensions PASSED
astropy/time/tests/test_basic.py::TestBasic::test_copy_time[2455197.5] PASSED
astropy/time/tests/test_basic.py::TestBasic::test_copy_time[value1] PASSED
astropy/time/tests/test_basic.py::TestBasic::test_getitem PASSED
astropy/time/tests/test_basic.py::TestBasic::test_properties PASSED
astropy/time/tests/test_basic.py::TestBasic::test_precision PASSED
astropy/time/tests/test_basic.py::TestBasic::test_transforms PASSED
astropy/time/tests/test_basic.py::TestBasic::test_location PASSED
astropy/time/tests/test_basic.py::TestBasic::test_location_array PASSED
astropy/time/tests/test_basic.py::TestBasic::test_all_transforms PASSED
astropy/time/tests/test_basic.py::TestBasic::test_creating_all_formats PASSED
astropy/time/tests/test_basic.py::TestBasic::test_datetime PASSED
astropy/time/tests/test_basic.py::TestBasic::test_epoch_transform PASSED
astropy/time/tests/test_basic.py::TestBasic::test_input_validation PASSED
astropy/time/tests/test_basic.py::TestBasic::test_utc_leap_sec PASSED
astropy/time/tests/test_basic.py::TestBasic::test_init_from_time_objects PASSED
astropy/time/tests/test_basic.py::TestVal2::test_val2_ignored PASSED
astropy/time/tests/test_basic.py::TestVal2::test_val2 PASSED
astropy/time/tests/test_basic.py::TestVal2::test_val_broadcasts_against_val2 PASSED
astropy/time/tests/test_basic.py::TestSubFormat::test_input_subformat PASSED
astropy/time/tests/test_basic.py::TestSubFormat::test_input_subformat_fail PASSED
astropy/time/tests/test_basic.py::TestSubFormat::test_bad_input_subformat PASSED
astropy/time/tests/test_basic.py::TestSubFormat::test_output_subformat PASSED
astropy/time/tests/test_basic.py::TestSubFormat::test_fits_format PASSED
astropy/time/tests/test_basic.py::TestSubFormat::test_yday_format PASSED
astropy/time/tests/test_basic.py::TestSubFormat::test_scale_input PASSED
astropy/time/tests/test_basic.py::TestSubFormat::test_fits_scale PASSED
astropy/time/tests/test_basic.py::TestSubFormat::test_fits_scale_representation PASSED
astropy/time/tests/test_basic.py::TestSubFormat::test_scale_default PASSED
astropy/time/tests/test_basic.py::TestSubFormat::test_epoch_times PASSED
astropy/time/tests/test_basic.py::TestSofaErrors::test_bad_time PASSED
astropy/time/tests/test_basic.py::TestCopyReplicate::test_immutable_input PASSED
astropy/time/tests/test_basic.py::TestCopyReplicate::test_replicate FAILED
astropy/time/tests/test_basic.py::TestCopyReplicate::test_copy PASSED
astropy/time/tests/test_basic.py::test_python_builtin_copy PASSED
astropy/time/tests/test_basic.py::test_now PASSED
astropy/time/tests/test_basic.py::test_decimalyear PASSED
astropy/time/tests/test_basic.py::test_fits_year0 PASSED
astropy/time/tests/test_basic.py::test_fits_year10000 PASSED
astropy/time/tests/test_basic.py::test_dir PASSED
astropy/time/tests/test_basic.py::test_bool PASSED
astropy/time/tests/test_basic.py::test_len_size PASSED
astropy/time/tests/test_basic.py::test_TimeFormat_scale PASSED
astropy/time/tests/test_basic.py::test_scale_conversion PASSED
astropy/time/tests/test_basic.py::test_byteorder PASSED
astropy/time/tests/test_basic.py::test_datetime_tzinfo PASSED
astropy/time/tests/test_basic.py::test_subfmts_regex PASSED
astropy/time/tests/test_basic.py::test_set_format_basic PASSED
astropy/time/tests/test_basic.py::test_set_format_shares_subfmt PASSED
astropy/time/tests/test_basic.py::test_set_format_does_not_share_subfmt PASSED
astropy/time/tests/test_basic.py::test_replicate_value_error PASSED
astropy/time/tests/test_basic.py::test_remove_astropy_time PASSED
astropy/time/tests/test_basic.py::test_isiterable PASSED
astropy/time/tests/test_basic.py::test_to_datetime PASSED
astropy/time/tests/test_basic.py::test_to_datetime_pytz PASSED
astropy/time/tests/test_basic.py::test_cache PASSED
astropy/time/tests/test_basic.py::test_epoch_date_jd_is_day_fraction PASSED
astropy/time/tests/test_basic.py::test_sum_is_equivalent PASSED
astropy/time/tests/test_comparisons.py::TestTimeComparisons::test_miscompares PASSED
astropy/time/tests/test_comparisons.py::TestTimeComparisons::test_time PASSED
astropy/time/tests/test_comparisons.py::TestTimeComparisons::test_timedelta PASSED
astropy/time/tests/test_corrs.py::TestHelioBaryCentric::test_heliocentric PASSED
astropy/time/tests/test_corrs.py::TestHelioBaryCentric::test_barycentric PASSED
astropy/time/tests/test_corrs.py::TestHelioBaryCentric::test_arrays PASSED
astropy/time/tests/test_corrs.py::TestHelioBaryCentric::test_ephemerides SKIPPED
astropy/time/tests/test_delta.py::TestTimeDelta::test_sub PASSED
astropy/time/tests/test_delta.py::TestTimeDelta::test_add PASSED
astropy/time/tests/test_delta.py::TestTimeDelta::test_add_vector PASSED
astropy/time/tests/test_delta.py::TestTimeDelta::test_sub_vector PASSED
astropy/time/tests/test_delta.py::TestTimeDelta::test_copy_timedelta[values0] PASSED
astropy/time/tests/test_delta.py::TestTimeDelta::test_copy_timedelta[values1] PASSED
astropy/time/tests/test_delta.py::TestTimeDelta::test_neg_abs PASSED
astropy/time/tests/test_delta.py::TestTimeDelta::test_mul_div PASSED
astropy/time/tests/test_delta.py::TestTimeDelta::test_keep_properties PASSED
astropy/time/tests/test_delta.py::TestTimeDelta::test_set_format PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_delta_scales_definition PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tai-tai] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tai-tcb] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tai-tcg] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tai-tdb] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tai-tt] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tai-ut1] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tai-utc] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tcb-tai] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tcb-tcb] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tcb-tcg] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tcb-tdb] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tcb-tt] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tcb-ut1] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tcb-utc] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tcg-tai] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tcg-tcb] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tcg-tcg] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tcg-tdb] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tcg-tt] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tcg-ut1] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tcg-utc] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tdb-tai] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tdb-tcb] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tdb-tcg] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tdb-tdb] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tdb-tt] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tdb-ut1] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tdb-utc] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tt-tai] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tt-tcb] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tt-tcg] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tt-tdb] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tt-tt] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tt-ut1] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[tt-utc] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[ut1-tai] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[ut1-tcb] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[ut1-tcg] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[ut1-tdb] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[ut1-tt] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[ut1-ut1] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[ut1-utc] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[utc-tai] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[utc-tcb] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[utc-tcg] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[utc-tdb] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[utc-tt] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[utc-ut1] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_time_minus_time[utc-utc] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_delta_minus_delta PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_delta_scale_is_none[tai-op0] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_delta_scale_is_none[tai-op1] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_delta_scale_is_none[tcb-op2] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_delta_scale_is_none[tcb-op3] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_delta_scale_is_none[tcg-op4] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_delta_scale_is_none[tcg-op5] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_delta_scale_is_none[tdb-op6] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_delta_scale_is_none[tdb-op7] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_delta_scale_is_none[tt-op8] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_delta_scale_is_none[tt-op9] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_delta_scale_is_none[ut1-op10] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_delta_scale_is_none[ut1-op11] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_delta_scale_is_none[utc-op12] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_scales_for_delta_scale_is_none[utc-op13] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_delta_day_is_86400_seconds[tai] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_delta_day_is_86400_seconds[tcb] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_delta_day_is_86400_seconds[tcg] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_delta_day_is_86400_seconds[tdb] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_delta_day_is_86400_seconds[tt] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_delta_day_is_86400_seconds[ut1] PASSED
astropy/time/tests/test_delta.py::TestTimeDeltaScales::test_delta_day_is_86400_seconds[utc] PASSED
astropy/time/tests/test_guess.py::TestGuess::test_guess1 PASSED
astropy/time/tests/test_guess.py::TestGuess::test_guess2 PASSED
astropy/time/tests/test_guess.py::TestGuess::test_guess3 PASSED
astropy/time/tests/test_guess.py::TestGuess::test_guess4 PASSED
astropy/time/tests/test_methods.py::TestManipulation::test_ravel PASSED
astropy/time/tests/test_methods.py::TestManipulation::test_flatten PASSED
astropy/time/tests/test_methods.py::TestManipulation::test_transpose PASSED
astropy/time/tests/test_methods.py::TestManipulation::test_diagonal PASSED
astropy/time/tests/test_methods.py::TestManipulation::test_swapaxes PASSED
astropy/time/tests/test_methods.py::TestManipulation::test_reshape PASSED
astropy/time/tests/test_methods.py::TestManipulation::test_shape_setting PASSED
astropy/time/tests/test_methods.py::TestManipulation::test_squeeze PASSED
astropy/time/tests/test_methods.py::TestManipulation::test_add_dimension PASSED
astropy/time/tests/test_methods.py::TestManipulation::test_take PASSED
astropy/time/tests/test_methods.py::TestManipulation::test_broadcast PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argfuncs[kw0-min] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argfuncs[kw1-max] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argfuncs[kw2-sort] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argfuncs[kw3-min] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argfuncs[kw4-max] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argfuncs[kw5-sort] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argfuncs[kw6-min] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argfuncs[kw7-max] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argfuncs[kw8-sort] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argfuncs[kw9-min] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argfuncs[kw10-max] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argfuncs[kw11-sort] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argfuncs[kw12-min] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argfuncs[kw13-max] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argfuncs[kw14-sort] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_funcs[kw0-min] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_funcs[kw1-max] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_funcs[kw2-sort] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_funcs[kw3-min] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_funcs[kw4-max] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_funcs[kw5-sort] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_funcs[kw6-min] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_funcs[kw7-max] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_funcs[kw8-sort] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_funcs[kw9-min] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_funcs[kw10-max] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_funcs[kw11-sort] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_funcs[kw12-min] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_funcs[kw13-max] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_funcs[kw14-sort] PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argmin PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argmax PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_argsort PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_min PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_max PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_ptp PASSED
astropy/time/tests/test_methods.py::TestArithmetic::test_sort PASSED
astropy/time/tests/test_methods.py::test_regression PASSED
astropy/time/tests/test_pickle.py::TestPickle::test_pickle PASSED
astropy/time/tests/test_precision.py::test_addition PASSED
astropy/time/tests/test_precision.py::test_mult_div PASSED
astropy/time/tests/test_precision.py::test_init_variations PASSED
astropy/time/tests/test_precision.py::test_precision_exceeds_64bit PASSED
astropy/time/tests/test_precision.py::test_through_scale_change PASSED
astropy/time/tests/test_precision.py::test_iso_init PASSED
astropy/time/tests/test_precision.py::test_jd1_is_mult_of_half_or_one PASSED
astropy/time/tests/test_precision.py::test_precision_neg xfail
astropy/time/tests/test_precision.py::test_precision_epoch PASSED
astropy/time/tests/test_precision.py::test_leap_seconds_rounded_correctly PASSED
astropy/time/tests/test_quantity_interaction.py::TestTimeQuantity::test_valid_quantity_input PASSED
astropy/time/tests/test_quantity_interaction.py::TestTimeQuantity::test_invalid_quantity_input PASSED
astropy/time/tests/test_quantity_interaction.py::TestTimeQuantity::test_column_with_and_without_units PASSED
astropy/time/tests/test_quantity_interaction.py::TestTimeQuantity::test_no_quantity_input_allowed PASSED
astropy/time/tests/test_quantity_interaction.py::TestTimeQuantity::test_valid_quantity_operations PASSED
astropy/time/tests/test_quantity_interaction.py::TestTimeQuantity::test_invalid_quantity_operations PASSED
astropy/time/tests/test_quantity_interaction.py::TestTimeDeltaQuantity::test_valid_quantity_input PASSED
astropy/time/tests/test_quantity_interaction.py::TestTimeDeltaQuantity::test_invalid_quantity_input PASSED
astropy/time/tests/test_quantity_interaction.py::TestTimeDeltaQuantity::test_quantity_output PASSED
astropy/time/tests/test_quantity_interaction.py::TestTimeDeltaQuantity::test_valid_quantity_operations1 PASSED
astropy/time/tests/test_quantity_interaction.py::TestTimeDeltaQuantity::test_valid_quantity_operations2 PASSED
astropy/time/tests/test_quantity_interaction.py::TestTimeDeltaQuantity::test_invalid_quantity_operations PASSED
astropy/time/tests/test_quantity_interaction.py::TestTimeDeltaQuantity::test_invalid_quantity_broadcast PASSED
astropy/time/tests/test_quantity_interaction.py::TestDeltaAttributes::test_delta_ut1_utc PASSED
astropy/time/tests/test_quantity_interaction.py::TestDeltaAttributes::test_delta_tdb_tt PASSED
astropy/time/tests/test_sidereal.py::test_doc_string_contains_models PASSED
astropy/time/tests/test_sidereal.py::TestERFATestCases::test_iau_models[erfa_test_input0] PASSED
astropy/time/tests/test_sidereal.py::TestERFATestCases::test_iau_models[erfa_test_input1] PASSED
astropy/time/tests/test_sidereal.py::TestERFATestCases::test_iau_models[erfa_test_input2] PASSED
astropy/time/tests/test_sidereal.py::TestERFATestCases::test_iau_models[erfa_test_input3] PASSED
astropy/time/tests/test_sidereal.py::TestERFATestCases::test_iau_models[erfa_test_input4] PASSED
astropy/time/tests/test_sidereal.py::TestERFATestCases::test_iau_models[erfa_test_input5] PASSED
astropy/time/tests/test_sidereal.py::TestERFATestCases::test_iau_models[erfa_test_input6] PASSED
astropy/time/tests/test_sidereal.py::TestST::test_gmst PASSED
astropy/time/tests/test_sidereal.py::TestST::test_gst PASSED
astropy/time/tests/test_sidereal.py::TestST::test_gmst_gst_close PASSED
astropy/time/tests/test_sidereal.py::TestST::test_gmst_independent_of_self_location PASSED
astropy/time/tests/test_sidereal.py::TestST::test_lst[mean] PASSED
astropy/time/tests/test_sidereal.py::TestST::test_lst[apparent] PASSED
astropy/time/tests/test_sidereal.py::TestST::test_lst_needs_location PASSED
astropy/time/tests/test_sidereal.py::TestModelInterpretation::test_model_uniqueness[mean] PASSED
astropy/time/tests/test_sidereal.py::TestModelInterpretation::test_model_uniqueness[apparent] PASSED
astropy/time/tests/test_sidereal.py::TestModelInterpretation::test_wrong_models_raise_exceptions[mean-apparent] PASSED
astropy/time/tests/test_sidereal.py::TestModelInterpretation::test_wrong_models_raise_exceptions[apparent-mean] PASSED
astropy/time/tests/test_ut1.py::TestTimeUT1::test_utc_to_ut1 PASSED
astropy/time/tests/test_ut1.py::TestTimeUT1::test_ut1_to_utc PASSED
astropy/time/tests/test_ut1.py::TestTimeUT1::test_delta_ut1_utc PASSED
astropy/time/tests/test_ut1.py::TestTimeUT1_IERSA::test_ut1_iers_A SKIPPED
astropy/time/tests/test_ut1.py::TestTimeUT1_IERS_Auto::test_ut1_iers_auto SKIPPED

======================================= FAILURES ========================================
_________________________________ TestBasic.test_simple _________________________________

self = <astropy.time.tests.test_basic.TestBasic object at 0x7f72ec7a56d8>

    def test_simple(self):
        times = ['1999-01-01 00:00:00.123456789', '2010-01-01 00:00:00']
        t = Time(times, format='iso', scale='utc')
        assert (repr(t) == "<Time object: scale='utc' format='iso' "
                "value=['1999-01-01 00:00:00.123' '2010-01-01 00:00:00.000']>")
>       assert allclose_jd(t.jd1, np.array([2451179.5, 2455197.5]))
E       AssertionError: assert False
E        +  where False = allclose_jd(array([ 2451180.,  2455198.]), array([ 2451179.5,  2455197.5]))
E        +    where array([ 2451180.,  2455198.]) = <Time object: scale='utc' format='iso' value=['1999-01-01 00:00:00.123' '2010-01-01 00:00:00.000']>.jd1
E        +    and   array([ 2451179.5,  2455197.5]) = <built-in function array>([2451179.5, 2455197.5])
E        +      where <built-in function array> = np.array

astropy/time/tests/test_basic.py:51: AssertionError
___________________________ TestCopyReplicate.test_replicate ____________________________

self = <astropy.time.tests.test_basic.TestCopyReplicate object at 0x7f72ea6ac240>

    def test_replicate(self):
        """Test replicate method"""
        t = Time('2000:001', format='yday', scale='tai',
                 location=('45d', '45d'))
        t_yday = t.yday
        t_loc_x = t.location.x.copy()
        t2 = t.replicate()
        assert t.yday == t2.yday
        assert t.format == t2.format
        assert t.scale == t2.scale
        assert t.location == t2.location
        # This is not allowed publicly, but here we hack the internal time
        # and location values to show that t and t2 are sharing references.
        t2._time.jd1 += 100.0
    
        # Need to delete the cached yday attributes (only an issue because
        # of the internal _time hack).
        del t.cache
        del t2.cache
    
>       assert t.yday == t2.yday
E       AssertionError: assert '2000:001:00:00:00.000' == '2000:101:00:00:00.000'
E         - 2000:001:00:00:00.000
E         ?      ^
E         + 2000:101:00:00:00.000
E         ?      ^

astropy/time/tests/test_basic.py:771: AssertionError
============== 2 failed, 245 passed, 3 skipped, 1 xfailed in 2.63 seconds ===============

@astropy-bot

astropy-bot Bot commented Oct 3, 2017 •

Copy link
Copy Markdown

Hi there @Juanlu001 👋 - thanks for the pull request! I'm just a friendly 🤖 that checks for issues related to the changelog and making sure that this pull request is milestoned and labeled correctly. This is mainly intended for the maintainers, so if you are not a maintainer you can ignore this, and a maintainer will let you know if any action is required on your part 😃.

Everything looks good from my point of view! 👍

If there are any issues with this message, please report them here.

@mhvk

mhvk commented Oct 3, 2017

Copy link
Copy Markdown
Contributor

@Juanlu001 - the first error is not a problem - in that case, it is fine to adjust the test, but the second is weird...

@mhvk

mhvk commented Oct 4, 2017

Copy link
Copy Markdown
Contributor

@Juanlu001 - that first test failing is OK, since the jd1 and jd2 are now different. The second one is a bit weirder, but is the result of the fact that with day_frac, numpy array scalars are turned into numpy float. And those do not share memory. Here, the fact that the test worked at all was in some sense just a coincidence of choosing a string for scalar input. I fixed this by making it a single-item array of time.

But it turns out there are more tests that fail... I fixed those, plus the failing doctests, and am left wondering if this is worth it. The alternative would be to adjust __add__ and __sub__, or, if one wanted to keep changes to tests more minimal, to adjust day_frac to really return a truncated day and fraction for jd1 and jd2. The advantage of the present PR is that by ensuring one always has -0.5<=jd2<0.5 one minimizes rounding error.

@astrojuanlu

Copy link
Copy Markdown
Member Author

I guess this deserves deeper discussion then. I would love to hear other opinions before going forward as well.

@astrojuanlu

astrojuanlu commented Oct 12, 2017 •

Copy link
Copy Markdown
Member Author

I was hit by this today again, and I would like to try the alternative approach of adjusting __add__ and __sub__ so they preserve precision while doing operations, I guess fewer things will break. While we decide, I will keep the old commits and do the work in this same branch, I guess we can squash and rebase later. @mhvk any other thing I should take into account?

astrojuanlu added a commit to astrojuanlu/poliastro that referenced this pull request Oct 12, 2017
The time arithmetic is again causing a loss of precision,
see astropy/astropy#6653 for an
attempt to fix it.
@mhvk

mhvk commented Oct 12, 2017

Copy link
Copy Markdown
Contributor

@Juanlu001 - with a bit more thought, I think I've come around to liking this approach more - we had those day_frac everywhere for a reason; that they weren't in some format classes is almost surely an oversight. Let me ping @taldcroft (though I know he is on holidays).

@taldcroft

Copy link
Copy Markdown
Member

👍 on this approach. I'm not sure it is perfect [1], but certainly a real improvement and consistent with practice elsewhere.

Of course it is failing the new tests at the moment... @Juanlu001 - was it passing tests locally? That should normally be a precondition before pushing to github.

[1]: But I do see the point that this solution is probably as good as necessary since the Julian Date format by definition is starting from float64 precision.

@astrojuanlu

Copy link
Copy Markdown
Member Author

@taldcroft Yes, it's failing because I reverted - but I just reverted the reversion :)

@mhvk There were some failing doctests on Windows and OS X in your last commit, though.

@astrojuanlu

Copy link
Copy Markdown
Member Author

Closing and reopening.

@astrojuanlu astrojuanlu reopened this Oct 12, 2017
@astrojuanlu

Copy link
Copy Markdown
Member Author

I cannot reproduce these failures locally. Trying to match the output of the CI yields this:

Details
$ python setup.py test -a "-k 'astropy.io.misc.yaml'"
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
running test
running build
running build_py
running pre_hook from astropy._erfa.setup_package for build_py command
running pre_hook from astropy.modeling.setup_package for build_py command
copying astropy/io/misc/yaml.py -> build/lib.linux-x86_64-3.6/astropy/io/misc
running build_ext
running pre_hook from astropy._erfa.setup_package for build_ext command
running pre_hook from astropy.modeling.setup_package for build_ext command
building 'astropy._compiler' extension
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/juanlu/.miniconda36/envs/astropy36_dev/include/python3.6m -c astropy/_compiler.c -o build/temp.linux-x86_64-3.6/astropy/_compiler.o
gcc -pthread -shared -L/home/juanlu/.miniconda36/envs/astropy36_dev/lib -Wl,-rpath=/home/juanlu/.miniconda36/envs/astropy36_dev/lib,--no-as-needed build/temp.linux-x86_64-3.6/astropy/_compiler.o -L/home/juanlu/.miniconda36/envs/astropy36_dev/lib -lpython3.6m -o build/lib.linux-x86_64-3.6/astropy/_compiler.cpython-36m-x86_64-linux-gnu.so
skipping 'astropy/table/_np_utils.c' Cython extension (up-to-date)
skipping 'astropy/table/_column_mixins.c' Cython extension (up-to-date)
skipping 'astropy/io/ascii/cparser.c' Cython extension (up-to-date)
skipping 'astropy/cosmology/scalar_inv_efuncs.c' Cython extension (up-to-date)
skipping 'astropy/convolution/boundary_extend.c' Cython extension (up-to-date)
skipping 'astropy/convolution/boundary_wrap.c' Cython extension (up-to-date)
skipping 'astropy/convolution/boundary_fill.c' Cython extension (up-to-date)
skipping 'astropy/convolution/boundary_none.c' Cython extension (up-to-date)
skipping 'astropy/stats/lombscargle/implementations/cython_impl.c' Cython extension (up-to-date)
/home/juanlu/.miniconda36/envs/astropy36_dev/lib/python3.6/importlib/_bootstrap.py:205: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
  return f(*args, **kwds)
========================================================= test session starts ==========================================================
platform linux -- Python 3.6.2, pytest-3.2.2, py-1.4.34, pluggy-0.4.0

Running tests with Astropy version 3.0.dev20389.
Running tests in lib.linux-x86_64-3.6/astropy docs.

Date: 2017-10-17T23:46:10

Platform: Linux-4.10.0-37-generic-x86_64-with-debian-stretch-sid

Executable: /home/juanlu/.miniconda36/envs/astropy36_dev/bin/python

Full Python Version: 
3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:51:32) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]

encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8
byteorder: little
float info: dig: 15, mant_dig: 15

Numpy: 1.12.1
Scipy: 0.19.1
Matplotlib: not available
h5py: not available
Pandas: not available
Cython: 0.26.1
Using Astropy options: remote_data: none.

rootdir: /tmp/astropy-test-dw9swpvk, inifile: setup.cfg
plugins: cov-2.5.1
collected 10137 items / 35 skipped                                                                                                      

astropy/io/misc/yaml.py F

=============================================================== FAILURES ===============================================================
____________________________________________________ [doctest] astropy.io.misc.yaml ____________________________________________________
031   >>> from astropy.io.misc import yaml
032   >>> import astropy.units as u
033   >>> from astropy.time import Time
034   >>> from astropy.coordinates import EarthLocation
035 
036   >>> t = Time(2457389.0, format='mjd',
037   ...          location=EarthLocation(1000, 2000, 3000, unit=u.km))
038   >>> td = yaml.dump(t)
039 
040   >>> print(td)
Differences (unified diff with -expected +actual):
    @@ -2,6 +2,6 @@
     format: mjd
     in_subfmt: '*'
    -jd1: 4857390.0
    -jd2: -0.5
    +jd1: 4857389.5
    +jd2: 0.0
     location: !astropy.coordinates.earth.EarthLocation
       ellipsoid: WGS84
    @@ -18,2 +18,3 @@
     precision: 3
     scale: utc
    +<BLANKLINE>

/tmp/astropy-test-dw9swpvk/lib.linux-x86_64-3.6/astropy/io/misc/yaml.py:40: DocTestFailure
======================================================== 10136 tests deselected ========================================================
======================================= 1 failed, 35 skipped, 10136 deselected in 22.75 seconds ========================================

@astrojuanlu

Copy link
Copy Markdown
Member Author

I tried several NumPy versions, default and conda-forge, with and without MKL... still can't reproduce. Not sure what's happening here 😕

@taldcroft

taldcroft commented Nov 3, 2017 •

Copy link
Copy Markdown
Member

@Juanlu001 - the failing doctest should be fine to just fix. This looks like an acceptable change in the jd1/2 representation, from 4857389.5 + 0.0 to 4857390.0 - 0.5.

I'm a little confused about saying "I cannot reproduce these failures locally". I am able to reproduce the current CI failures, and it looks like you did too. ??

@astrojuanlu

Copy link
Copy Markdown
Member Author

You were right, it worked! Probably an installation problem on my end. Should I add a changelog entry or something?

@mhvk mhvk changed the title WIP: Fix jd1 and jd2 format Fix jd1 and jd2 format Nov 5, 2017

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks all OK. I would add a changelog entry since I feel this has fixed a small buglet. That would mean it should also be backported, so add it under 2.0.3. It can just refer to the fact the initialization was made consistent for all formats.

@astrojuanlu

Copy link
Copy Markdown
Member Author

Done!

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, all fine now. Merging!

@mhvk
mhvk merged commit 4fd4aa5 into astropy:master Nov 6, 2017
@astrojuanlu
astrojuanlu deleted the fix-day-frac branch November 6, 2017 14:39
bsipocz pushed a commit that referenced this pull request Nov 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Time("J2000") and equivalents should be equal

4 participants