Skip to content

Very many tests (86 errors, 5 failures) do not pass  #4850

Closed

Description

@TheChymera

I maintain statsmodels for Gentoo Linux, and I recently tried to run the test suite for 0.9.0.

A lot of the suite will not pass. See the full build log including build/install output and test output at the end.

The test suite is executed with

nosetests -v

Activity

  1. TheChymera commented on Aug 8, 2018

    @TheChymera
    Author

    I now see that you may have moved to py.test, but I still see nose cropping up a lot in the source code and listed under the dependencies. Is there any other way I should be running the tests?

  2. bashtage commented on Aug 8, 2018

    @bashtage
    Member
    python setup.py develop
    pytest statsmodels
  3. bashtage commented on Aug 8, 2018

    @bashtage
    Member

    Warnings are not counted as errors or failures. Some of you failures are from using packages released after 0.9.0, e.g., TypeError: __new__() got an unexpected keyword argument 'format'

  4. TheChymera commented on Aug 8, 2018

    @TheChymera
    Author

    ok, py.test -v seems to give if not better at least different results: http://bpaste.net/show/f7dbfbb8dc00

    The main error message now seems to be ImportError: cannot import name _representation.

    ome of you failures are from using packages released after 0.9.0
    You mean dependency versions which are “too new” for =statsmodels-0.9.0? Like which ones?

  5. bashtage commented on Aug 8, 2018

    @bashtage
    Member

    This means that something isn't being built when running setup since this is an extension module.

    TypeError: __new__() got an unexpected keyword argument 'format' is due to changes in pandas after 0.9. You can pin pandas to <=0.22 or use master.

  6. TheChymera commented on Aug 8, 2018

    @TheChymera
    Author

    @bashtage what exactly is an extension module? You mean statsmodels bundles some external lib?

  7. bashtage commented on Aug 8, 2018

    @bashtage
    Member

    An extension module is a compiled module. All of the errors I saw were because these weren't being built.

    What happens if you just run

    git checkout tags/v0.9.0
    python setup.py develop
    pytest statsmodels
    

    This can also happen you are running the test suite from the statsmodels directory and have called python setup.py install. This happens since there are inti.py files in the directory below, and it will prefer local over site packages.

  8. jbrockmendel commented on Aug 9, 2018

    @jbrockmendel
    Contributor

    Might need “python setup.py build_ext --inplace”?

  9. jbrockmendel commented on Aug 19, 2018

    @jbrockmendel
    Contributor

    @TheChymera did this get sorted out?

  10. bashtage commented on Sep 12, 2018

    @bashtage
    Member

    @josef-pkt I think this can be closed.

  11. josef-pkt commented on Sep 12, 2018

    @josef-pkt
    Member

    closing, assuming there is nothing left to fix here

  12. TheChymera commented on Sep 19, 2018

    @TheChymera
    Author

    @bashtage @jbrockmendel @josef-pkt sorry guys, this got buried in other work.

    Apparently I was running the tests from the wrong directory. Now most errors got taken care of, the log, however, still shows one:

    E   AttributeError: 'DatetimeIndex' object has no attribute 'to_datetime'
    

    I thought this might be a Pandas version issue (I am using =dev-python/pandas-0.23.4), but SO shows it might actually be incorrect syntax?

  13. jbrockmendel commented on Sep 19, 2018

    @jbrockmendel
    Contributor

    Yah, the appropriate DatetimeIndex method would be to_pydatetime. I'm pretty sure this usage is fixed in statsmodels master.

  14. TheChymera commented on Sep 19, 2018

    @TheChymera
    Author

    @jbrockmendel ok, thanks :)

    The master branch seems to give a lot of errors though. Any ideas about this?

  15. 22 remaining items

  16. josef-pkt commented on Sep 24, 2018

    @josef-pkt
    Member

    I reopened so the issue is easier to find.

  17. josef-pkt commented on Sep 24, 2018

    @josef-pkt
    Member

    trying to find previous failure for line endings
    file search for "splitlines" finds only one likely candidate
    in multivariate test_factor.py

        actual = results.summary().as_text()
        actual = "\n".join(line.rstrip() for line in actual.splitlines()) + "\n"
        assert_equal(actual, desired)
    
  18. TheChymera commented on Sep 24, 2018

    @TheChymera
    Author

    @bashtage regarding the LOCALE:

    zenhost ~ # localectl
       System Locale: LANG=en_GB.utf8
                      LC_NUMERIC=en_GB.UTF-8
                      LC_TIME=en_GB.UTF-8
                      LC_MONETARY=en_GB.UTF-8
                      LC_PAPER=en_GB.UTF-8
                      LC_MEASUREMENT=en_GB.UTF-8
           VC Keymap: sg
          X11 Layout: ch,ru
         X11 Variant: ,
    
  19. TheChymera commented on Sep 24, 2018

    @TheChymera
    Author

    interesting, after I xfail-ed the test_start_params_bug function, another failure (test_hdr_multiple_aplha) cropped up:

    http://bpaste.net/show/081a80130517

    how is that possible?

  20. bashtage commented on Sep 24, 2018

    @bashtage
    Member

    It happens because some tests use the global numpy randomstate singleton, and so can fail from run-to-run depending on how the tests are ordered and the initial seed to the generator. These have mostly been fixed in master, but can't be helped in 0.9.

  21. bashtage commented on Sep 24, 2018

    @bashtage
    Member

    LOCALE looks normal to me, but I'm not an expert.

  22. TheChymera commented on Sep 25, 2018

    @TheChymera
    Author

    @josef-pkt @bashtage O, now that I've xfailed all the tests that were failing on 2.7 a (mostly non-overlapping) new set of tests seems to fail on 3.6.

    There's the full log, and here again the acute snippet. Also, please see how in the full log a number of tests xpass. These are the ones I had marked as failing for 2.7. Interesting how this is complementary...

    =============================================== FAILURES ================================================
    ______________________________ test_single_factor_repeated_measures_anova _______________________________
    
        def test_single_factor_repeated_measures_anova():
            """
            Testing single factor repeated measures anova
            Results reproduces R `ezANOVA` function from library ez
            """
            df = AnovaRM(data.iloc[:16, :], 'DV', 'id', within=['B']).fit()
            a = [[1, 7, 22.4, 0.002125452]]
            assert_array_almost_equal(df.anova_table.iloc[:, [1, 2, 0, 3]].values,
    >                                 a, decimal=5)
    E       AssertionError: 
    E       Arrays are not almost equal to 5 decimals
    E       
    E       (mismatch 75.0%)
    E        x: array([[7.00000e+00, 2.24000e+01, 1.00000e+00, 2.12545e-03]])
    E        y: array([[1.00000e+00, 7.00000e+00, 2.24000e+01, 2.12545e-03]])
    
    lib/statsmodels/stats/tests/test_anova_rm.py:88: AssertionError
    _______________________________ test_two_factors_repeated_measures_anova ________________________________
    
        def test_two_factors_repeated_measures_anova():
            """
            Testing two factors repeated measures anova
            Results reproduces R `ezANOVA` function from library ez
            """
            df = AnovaRM(data.iloc[:48, :], 'DV', 'id', within=['A', 'B']).fit()
            a = [[1, 7, 40.14159, 3.905263e-04],
                 [2, 14, 29.21739, 1.007549e-05],
                 [2, 14, 17.10545, 1.741322e-04]]
            assert_array_almost_equal(df.anova_table.iloc[:,[1, 2, 0, 3]].values,
    >                                 a, decimal=5)
    E       AssertionError: 
    E       Arrays are not almost equal to 5 decimals
    E       
    E       (mismatch 75.0%)
    E        x: array([[7.00000e+00, 4.01416e+01, 1.00000e+00, 3.90526e-04],
    E              [1.40000e+01, 2.92174e+01, 2.00000e+00, 1.00755e-05],
    E              [1.40000e+01, 1.71055e+01, 2.00000e+00, 1.74132e-04]])
    E        y: array([[1.00000e+00, 7.00000e+00, 4.01416e+01, 3.90526e-04],
    E              [2.00000e+00, 1.40000e+01, 2.92174e+01, 1.00755e-05],
    E              [2.00000e+00, 1.40000e+01, 1.71055e+01, 1.74132e-04]])
    
    lib/statsmodels/stats/tests/test_anova_rm.py:101: AssertionError
    ______________________________ test_three_factors_repeated_measures_anova _______________________________
    
        def test_three_factors_repeated_measures_anova():
            """
            Testing three factors repeated measures anova
            Results reproduces R `ezANOVA` function from library ez
            """
            df = AnovaRM(data, 'DV', 'id', within=['A', 'B', 'D']).fit()
            a = [[1,  7,  8.7650709, 0.021087505],
                 [2, 14,  8.4985785, 0.003833921],
                 [1,  7, 20.5076546, 0.002704428],
                 [2, 14,  0.8457797, 0.450021759],
                 [1,  7, 21.7593382, 0.002301792],
                 [2, 14,  6.2416695, 0.011536846],
                 [2, 14,  5.4253359, 0.018010647]]
            assert_array_almost_equal(df.anova_table.iloc[:,[1, 2, 0, 3]].values,
    >                                 a, decimal=5)
    E       AssertionError: 
    E       Arrays are not almost equal to 5 decimals
    E       
    E       (mismatch 75.0%)
    E        x: array([[7.00000e+00, 8.76507e+00, 1.00000e+00, 2.10875e-02],
    E              [1.40000e+01, 8.49858e+00, 2.00000e+00, 3.83392e-03],
    E              [7.00000e+00, 2.05077e+01, 1.00000e+00, 2.70443e-03],...
    E        y: array([[1.00000e+00, 7.00000e+00, 8.76507e+00, 2.10875e-02],
    E              [2.00000e+00, 1.40000e+01, 8.49858e+00, 3.83392e-03],
    E              [1.00000e+00, 7.00000e+00, 2.05077e+01, 2.70443e-03],...
    
    lib/statsmodels/stats/tests/test_anova_rm.py:118: AssertionError
    _________________________ test_repeated_measures_aggregate_compare_with_ezANOVA _________________________
    
        def test_repeated_measures_aggregate_compare_with_ezANOVA():
            # Results should reproduces those from R's `ezANOVA` (library ez).
            ez = pd.DataFrame(
                {'F Value': [8.7650709, 8.4985785, 20.5076546, 0.8457797, 21.7593382,
                             6.2416695, 5.4253359],
                 'Num DF': [1, 2, 1, 2, 1, 2, 2],
                 'Den DF': [7, 14, 7, 14, 7, 14, 14],
                 'Pr > F': [0.021087505, 0.003833921, 0.002704428, 0.450021759,
                            0.002301792, 0.011536846, 0.018010647]},
                index=pd.Index(['A', 'B', 'D', 'A:B', 'A:D', 'B:D', 'A:B:D']))
            ez = ez[['F Value', 'Num DF', 'Den DF', 'Pr > F']]
        
            df = (AnovaRM(data.append(data), 'DV', 'id', within=['A', 'B', 'D'],
                          aggregate_func=np.mean)
                  .fit()
                  .anova_table)
        
    >       assert_frame_equal(ez, df, check_dtype=False)
    
    lib/statsmodels/stats/tests/test_anova_rm.py:198: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    /usr/lib64/python3.6/site-packages/pandas/util/testing.py:1340: in assert_frame_equal
        obj='{obj}.columns'.format(obj=obj))
    /usr/lib64/python3.6/site-packages/pandas/util/testing.py:860: in assert_index_equal
        obj=obj, lobj=left, robj=right)
    pandas/_libs/testing.pyx:59: in pandas._libs.testing.assert_almost_equal
        ???
    pandas/_libs/testing.pyx:173: in pandas._libs.testing.assert_almost_equal
        ???
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    
    obj = 'DataFrame.columns', message = 'DataFrame.columns values are different (75.0 %)'
    left = Index(['F Value', 'Num DF', 'Den DF', 'Pr > F'], dtype='object')
    right = Index(['Num DF', 'Den DF', 'F Value', 'Pr > F'], dtype='object'), diff = None
    
        def raise_assert_detail(obj, message, left, right, diff=None):
            if isinstance(left, np.ndarray):
                left = pprint_thing(left)
            elif is_categorical_dtype(left):
                left = repr(left)
        
            if PY2 and isinstance(left, string_types):
                # left needs to be printable in native text type in python2
                left = left.encode('utf-8')
        
            if isinstance(right, np.ndarray):
                right = pprint_thing(right)
            elif is_categorical_dtype(right):
                right = repr(right)
        
            if PY2 and isinstance(right, string_types):
                # right needs to be printable in native text type in python2
                right = right.encode('utf-8')
        
            msg = """{obj} are different
        
        {message}
        [left]:  {left}
        [right]: {right}""".format(obj=obj, message=message, left=left, right=right)
        
            if diff is not None:
                msg += "\n[diff]: {diff}".format(diff=diff)
        
    >       raise AssertionError(msg)
    E       AssertionError: DataFrame.columns are different
    E       
    E       DataFrame.columns values are different (75.0 %)
    E       [left]:  Index(['F Value', 'Num DF', 'Den DF', 'Pr > F'], dtype='object')
    E       [right]: Index(['Num DF', 'Den DF', 'F Value', 'Pr > F'], dtype='object')
    
    /usr/lib64/python3.6/site-packages/pandas/util/testing.py:1035: AssertionError
    

    Any idea what I can do about these?

  23. josef-pkt commented on Sep 25, 2018

    @josef-pkt
    Member

    What is your pandas version?

    Those are all column reorderings, IIRC because python 3.6 changed to ordered dict.
    Those are also supposed to be fixed in master

  24. TheChymera commented on Sep 25, 2018

    @TheChymera
    Author

    @josef-pkt

    chymera@zenhost ~ $ eix pandas
    [I] dev-python/pandas
         Available versions:  0.19.1 (~)0.23.0 (~)0.23.4 **9999 {X doc full-support (-)minimal test PYTHON_TARGETS="python2_7 python3_4 python3_5 python3_6"}
         Installed versions:  0.23.4(03:20:10 02/09/18)(X -doc -full-support -minimal -test PYTHON_TARGETS="python2_7 python3_6 -python3_5")
         Homepage:            http://pandas.pydata.org/
         Description:         Powerful data structures for data analysis and statistics
    

    So 0.23.4 but as you can see above there is a notable gap in versions on my distribution, so I cannot reasonably downgrade.

  25. josef-pkt commented on Sep 25, 2018

    @josef-pkt
    Member

    Essentially pandas and python and ... are changing too fast to keep up given our release schedule.
    Debian is using a patched version where they backport some of our fixes, when we are too slow in releasing statsmodels.

    Maybe with the recent changes in the setup.py and automatic doc and windows binaries building, it will become easier to quickly throw a minimal compat release at the public (especially if I don't have to be the release manager)

  26. cpoptic commented on Feb 28, 2019

    @cpoptic

    So bottom line, does statsmodels work with Pandas 0.24? I think it's standard operating procedure to use the most recent version of a library, so downgrading to Pandas 0.23 or 0.22 is a suboptimal solution. Can we get statsmodels to play nicely with Pandas 0.24?

  27. bashtage commented on Jul 17, 2019

    @bashtage
    Member

    Closing this since our test suite seems to pass reliably on many platforms. Please reopen if this is still an issue.

  28. added this to the 0.11 milestone on Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions