Skip to content

3.2rc1 Doctest failure in timeseries #8691

Description

@saimn

This is maybe related to the use of scipy 1.3.0rc2, I don't see this failure on another computer with scipy 1.2.1.

===================================== test session starts =====================================
platform linux -- Python 3.7.2, pytest-4.4.2, py-1.8.0, pluggy-0.11.0

Running tests with Astropy version 4.0.dev24575.
Running tests in astropy docs.

Date: 2019-05-10T10:13:56

Platform: Linux-5.0.13-arch1-1-ARCH-x86_64-with-arch

Executable: /home/simon/.pyenv/versions/3.7.2/bin/python

Full Python Version: 
3.7.2 (default, Jan 18 2019, 23:38:59) 
[GCC 8.2.1 20181127]

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

Numpy: 1.16.3
Scipy: 1.3.0rc2
Matplotlib: 3.0.3
h5py: 2.9.0
Pandas: 0.24.2
Cython: 0.29.7
Scikit-image: 0.15.0
astropy_helpers: 3.1rc1
Using Astropy options: remote_data: any.

_____________________________ [doctest] docs/timeseries/index.rst _____________________________
[gw2] linux -- Python 3.7.2 /home/simon/.pyenv/versions/3.7.2/bin/python
263    from astropy.stats import sigma_clipped_stats
264    mean, median, stddev = sigma_clipped_stats(ts_folded['sap_flux'])
265    ts_folded['sap_flux_norm'] = ts_folded['sap_flux'] / median
266 
267 and we can downsample the time series by binning the points into bins of equal
268 time - this returns a |BinnedTimeSeries|::
269 
270     >>> from astropy.timeseries import aggregate_downsample
271     >>> ts_binned = aggregate_downsample(ts_folded, time_bin_size=0.03 * u.day)  # doctest: +REMOTE_DATA
272     >>> ts_binned  # doctest: +FLOAT_CMP +REMOTE_DATA
Differences (unified diff with -expected +actual):
    @@ -1,25 +1,48 @@
     <BinnedTimeSeries length=74>
    -   time_bin_start     time_bin_size    ...   sap_flux_norm
    -                            s          ...
    -       object            float64       ...       float64
    -------------------- ------------------ ... ------------------
    --1.1022116370482966             2592.0 ... 0.9998741745948792
    --1.0722116370482966             2592.0 ... 0.9999074339866638
    --1.0422116370482966             2592.0 ...  0.999972939491272
    --1.0122116370482965             2592.0 ... 1.0000077486038208
    --0.9822116370482965             2592.0 ... 0.9999921917915344
    --0.9522116370482965             2592.0 ... 1.0000101327896118
    --0.9222116370482966             2592.0 ... 1.0000121593475342
    --0.8922116370482965             2592.0 ... 0.9999905228614807
    --0.8622116370482965 2592.0000000000023 ... 1.0000263452529907
    -                ...                ... ...                ...
    - 0.8177883629517035 2591.9999999999977 ... 1.0000624656677246
    - 0.8477883629517035 2592.0000000000014 ... 1.0000633001327515
    - 0.8777883629517035  2592.000000000019 ... 1.0000433921813965
    - 0.9077883629517037 2591.9999999999814 ...  1.000024676322937
    - 0.9377883629517034   2592.00000000002 ... 1.0000224113464355
    - 0.9677883629517037  2591.999999999981 ... 1.0000698566436768
    - 0.9977883629517035             2592.0 ... 0.9999606013298035
    - 1.0277883629517035             2592.0 ... 0.9999635815620422
    - 1.0577883629517035             2592.0 ... 0.9999105930328369
    - 1.0877883629517036 2592.0000000000095 ... 0.9998687505722046
    +   time_bin_start     time_bin_size    ...        pos_corr2          sap_flux_norm
    +                            s          ...           pix
    +       object            float64       ...         float64              float64
    +------------------- ------------------ ... ----------------------- ------------------
    +-1.1022116370482966             2592.0 ...  0.00031207725987769663 0.9998741745948792
    +-1.0722116370482966             2592.0 ...  0.00041217938996851444 0.9999074339866638
    +-1.0422116370482966             2592.0 ...  0.00039273229776881635  0.999972939491272
    +-1.0122116370482965             2592.0 ...   0.0002928022004198283 1.0000077486038208
    +-0.9822116370482965             2592.0 ...   0.0003891147789545357 0.9999921917915344
    +-0.9522116370482965             2592.0 ...   0.0003491091774776578 1.0000101327896118
    +-0.9222116370482966             2592.0 ...   0.0002824827388394624 1.0000121593475342
    +-0.8922116370482965             2592.0 ...  0.00016335179680027068 0.9999905228614807
    +-0.8622116370482965 2592.0000000000023 ...   0.0001397567830281332 1.0000263452529907
    +-0.8322116370482965 2591.9999999999977 ... -0.00014221783203538507  1.000070333480835
    +-0.8022116370482966 2592.0000000000023 ...  -9.427832264918834e-05 1.0000371932983398
    +-0.7722116370482965             2592.0 ... -0.00017664248298387975 1.0000463724136353
    +-0.7422116370482965 2592.0000000000023 ... -0.00012228667037561536 1.0000810623168945
    +-0.7122116370482965 2591.9999999999927 ...  -0.0001244118611793965 1.0000311136245728
    +-0.6822116370482966 2592.0000000000023 ...  -8.055769285419956e-05 1.0000026226043701
    +-0.6522116370482965 2592.0000000000023 ...  -0.0001010842970572412  1.000022530555725
    +-0.6222116370482965 2592.0000000000023 ...   -7.21014293958433e-06  1.000044822692871
    +-0.5922116370482965 2591.9999999999927 ...   8.348121627932414e-05 0.9999921917915344
    +-0.5622116370482966 2592.0000000000023 ...   9.918524301610887e-05 0.9999784827232361
    +-0.5322116370482965 2592.0000000000023 ...    6.90473461872898e-05 1.0000337362289429
    +-0.5022116370482965 2592.0000000000023 ...  0.00013223491259850562 1.0000052452087402
    +                ...                ... ...                     ...                ...
    +0.48778836295170347 2592.0000000000023 ...  0.00011087083112215623 1.0000249147415161
    + 0.5177883629517035 2592.0000000000023 ...   0.0001466787070967257 1.0000004768371582
    + 0.5477883629517035 2591.9999999999927 ...  0.00022175510821398348 1.0000418424606323
    + 0.5777883629517034 2592.0000000000023 ...   0.0001385248324368149 1.0000243186950684
    + 0.6077883629517035 2592.0000000000023 ...   7.515603647334501e-05 1.0000287294387817
    + 0.6377883629517035 2591.9999999999977 ...   0.0001684143499005586 1.0000258684158325
    + 0.6677883629517034 2591.9999999999977 ...  0.00011036244541173801 1.0000230073928833
    + 0.6977883629517034 2592.0000000000023 ...  0.00012551579857245088 1.0000182390213013
    + 0.7277883629517035             2592.0 ...   0.0002313474251423031 1.0000282526016235
    + 0.7577883629517035             2592.0 ...  0.00027140387101098895 1.0000109672546387
    + 0.7877883629517035 2592.0000000000023 ...  0.00011987287871306762 1.0000824928283691
    + 0.8177883629517035 2591.9999999999977 ... -2.2798192730988376e-05 1.0000624656677246
    + 0.8477883629517035 2592.0000000000014 ...  0.00022221534163691103 1.0000633001327515
    + 0.8777883629517035  2592.000000000019 ...  0.00019213277846574783 1.0000433921813965
    + 0.9077883629517037 2591.9999999999814 ...   0.0002187517675338313  1.000024676322937
    + 0.9377883629517034   2592.00000000002 ...  0.00016979355132207274 1.0000224113464355
    + 0.9677883629517037  2591.999999999981 ...  0.00014231358363758773 1.0000698566436768
    + 0.9977883629517035             2592.0 ...   0.0001224415173055604 0.9999606013298035
    + 1.0277883629517035             2592.0 ...  0.00027701034559868276 0.9999635815620422
    + 1.0577883629517035             2592.0 ...   0.0003093520936090499 0.9999105930328369
    + 1.0877883629517036 2592.0000000000095 ...  0.00022884277859702706 0.9998687505722046

/tmp/simon/astropy-test-beh0dhqh/lib/python3.7/site-packages/docs/timeseries/index.rst:272: DocTestFailure

Activity

  1. pllim commented on May 10, 2019

    @pllim
    Member

    The number of displayed columns is also different -- is this why doctest is failing? Can scipy influence the number of display columns?

  2. pllim commented on May 10, 2019

    @pllim
  3. added this to the v3.2 milestone on May 10, 2019
  4. bsipocz commented on May 10, 2019

    @bsipocz
    Member

    What happens if the line >>> ts_binned # doctest: +FLOAT_CMP +REMOTE_DATA is changed to >>> ts_binned # doctest: +FLOAT_CMP +REMOTE_DATA +ELLIPSIS?

  5. pllim commented on May 11, 2019

    @pllim
    Member

    @saimn , I am unable to reproduce the reported failure in CI. Are you sure scipy is the culprit and not screen resolution or something else? In #8695 , I forced the first job to install scipy 1.3.0rc2 and run with --remote-data but that job passed (https://travis-ci.org/astropy/astropy/jobs/531030649).

  6. bsipocz commented on May 11, 2019

    @bsipocz
    Member

    @saimn - what is the version of your pytest-doctestplus?

  7. saimn commented on May 11, 2019

    @saimn
    ContributorAuthor

    Hmm, I cannot reproduce with another laptop, I will try with the other one tomorrow or Monday.

  8. astrofrog commented on May 11, 2019

    @astrofrog
    Member

    @saimn - in the past, some of your test failures have been due to custom config in the astropy config file. Could you check whether there is anything in there related to terminal width?

  9. saimn commented on May 12, 2019

    @saimn
    ContributorAuthor

    So I can reproduce only when using pytest-xdist, with python setup.py test -R -j 2 -t docs/timeseries/index.rst. Without the -j the test pass.
    I can reproduce the same output in both cases with ts_binned.pprint(show_unit=True, show_dtype=True, max_width=80, max_lines=25), but it's a bit annoying to have in the docs ?

  10. bsipocz commented on May 13, 2019

    @bsipocz
    Member

    @saimn - can you confirm that adding +ELLIPSIS is not helping?

  11. saimn commented on May 13, 2019

    @saimn
    ContributorAuthor

    @bsipocz - Yes indeed, it is not helping.

  12. bsipocz commented on May 13, 2019

    @bsipocz
    Member

    that's then worth a bugreport to pytest-doctestplus

  13. 2 remaining items

  14. saimn commented on May 18, 2019

    @saimn
    ContributorAuthor

    So the failure is because os.environ.get('COLUMNS') returns the real terminal size when running with xdist:

    # see if POSIX standard variables will work
    return (int(os.environ.get('LINES')),
    int(os.environ.get('COLUMNS')))

    It seems that COLUMNS and LINES are set by the shell, but I still do not understand why this happens only for me and on this specific laptop ...

  15. astrofrog commented on May 19, 2019

    @astrofrog
    Member

    @saimn - I know you mentioned that in your case COLUMNS and LINES are not environment variables, just shell variables, but the fact that we do check the environment variables suggests to me that when running the tests we should make sure we temporarily remove these variables from the environment in case users did set them directly? (which would also incidentally fix your issue, though this wouldn't address the root cause)

  16. removed this from the v3.2 milestone on May 19, 2019
  17. astrofrog commented on May 19, 2019

    @astrofrog
    Member

    I'm removing the milestone since this isn't a regression as such, and not critical for v3.2

  18. saimn commented on May 19, 2019

    @saimn
    ContributorAuthor

    I agree it is not critical. These variables were added to handle the terminal resizing for the progress bar, so this must be useful at some point but I don't understand how it is supposed to happen. It may be a good idea to set these variables to the default values, indeed.

  19. astrofrog commented on Jun 18, 2019

    @astrofrog
    Member

    For anyone interested in working on this, the idea is to edit the conftest.py file(s) to temporarily unset COLUMNS and LINES (environment variables) during the tests.

  20. aarchiba commented on Oct 18, 2019

    @aarchiba
    Contributor

    I believe I'm seeing the same error. On a wide terminal I see:

    ====================================================== FAILURES =======================================================
    __________________________________________ [doctest] docs/timeseries/io.rst ___________________________________________
    091 :download:`binned.csv <binned.csv>` and with a column ``time_start`` giving the start time
    092 and ``bin_size`` giving the size of each bin, you can do::
    093 
    094     >>> from astropy import units as u
    095     >>> from astropy.timeseries import BinnedTimeSeries
    096     >>> ts = BinnedTimeSeries.read('docs/timeseries/binned.csv', format='ascii.csv',
    097     ...                            time_bin_start_column='time_start',
    098     ...                            time_bin_size_column='bin_size',
    099     ...                            time_bin_size_unit=u.s)
    100     >>> ts[:3]
    Differences (unified diff with -expected +actual):
        @@ -1,8 +1,8 @@
         <BinnedTimeSeries length=3>
        -     time_bin_start     time_bin_size ...    E       F
        -                              s       ...
        -         object            float64    ... float64 float64
        ------------------------ ------------- ... ------- -------
        -2016-03-22T12:30:31.000           3.0 ...   28.87   63.44
        -2016-03-22T12:30:34.000           3.0 ...   27.76   59.98
        -2016-03-22T12:30:37.000           3.0 ...   27.04   59.61
        +     time_bin_start     time_bin_size         time_end           A       B       C       D       E       F   
        +                              s                                                                              
        +         object            float64             str23          float64 float64 float64 float64 float64 float64
        +----------------------- ------------- ----------------------- ------- ------- ------- ------- ------- -------
        +2016-03-22T12:30:31.000           3.0 2016-03-22T12:30:34.000  164.93  114.73   26.27   19.21   28.87   63.44
        +2016-03-22T12:30:34.000           3.0 2016-03-22T12:30:37.000  164.89  114.75   26.22   19.07   27.76   59.98
        +2016-03-22T12:30:37.000           3.0 2016-03-22T12:30:40.000  164.63  115.04   25.78   19.01   27.04   59.61
    
    /tmp/astropy-test-5a03ndy4/lib/python3.7/site-packages/docs/timeseries/io.rst:100: DocTestFailure
    ======================== 1 failed, 13810 passed, 311 skipped, 58 xfailed in 209.08s (0:03:29) =========================
    

    The version actually observed is different depending on the width of my terminal when I run python setup.py test.

  21. pllim commented on Mar 29, 2022

    @pllim
    Member

    Can someone update the title? I almost closed it because the version reported is too old but looks like this is still a problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions