raphaelvallat / pingouin

Statistical package in Python based on Pandas
https://pingouin-stats.org/
GNU General Public License v3.0
1.6k stars 137 forks source link

Python 3.9: failing test: TestPlotting.test_plot_skipped_corr #99

Closed sanjayankur31 closed 4 years ago

sanjayankur31 commented 4 years ago

On Fedora 33, with Python 3.9, a test is failing:

+ export PYTHONPATH=/builddir/build/BUILDROOT/python-pingouin-0.3.3-2.fc33.noarch/usr/lib/python3.9/site-packages
+ PYTHONPATH=/builddir/build/BUILDROOT/python-pingouin-0.3.3-2.fc33.noarch/usr/lib/python3.9/site-packages
+ pytest-3.9
============================= test session starts ==============================
platform linux -- Python 3.9.0b1, pytest-5.4.2, py-1.8.0, pluggy-0.13.1
rootdir: /builddir/build/BUILD/pingouin-0.3.3, inifile: setup.cfg
plugins: sugar-0.9.2, cov-2.8.1, remotedata-0.3.1
collected 83 items
pingouin/tests/test_bayesian.py ...                                      [  3%]
pingouin/tests/test_circular.py .......                                  [ 12%]
pingouin/tests/test_contingency.py ....                                  [ 16%]
pingouin/tests/test_correlation.py ....                                  [ 21%]
pingouin/tests/test_distribution.py ......                               [ 28%]
pingouin/tests/test_effsize.py .....                                     [ 34%]
pingouin/tests/test_equivalence.py .                                     [ 36%]
pingouin/tests/test_multicomp.py .....                                   [ 42%]
pingouin/tests/test_multivariate.py ..                                   [ 44%]
pingouin/tests/test_nonparametric.py ........                            [ 54%]
pingouin/tests/test_pairwise.py ....                                     [ 59%]
pingouin/tests/test_pandas.py .                                          [ 60%]
pingouin/tests/test_parametric.py .......                                [ 68%]
pingouin/tests/test_plotting.py .....F..                                 [ 78%]
pingouin/tests/test_power.py ......                                      [ 85%]
pingouin/tests/test_regression.py ...                                    [ 89%]
pingouin/tests/test_reliability.py ..                                    [ 91%]
pingouin/tests/test_utils.py .......                                     [100%]
=================================== FAILURES ===================================
_____________________ TestPlotting.test_plot_skipped_corr ______________________
self = <pingouin.tests.test_plotting.TestPlotting testMethod=test_plot_skipped_corr>
    def test_plot_skipped_corr(self):
        """Test plot_skipped_corr()"""
        # Data for correlation
        np.random.seed(123)
        x, y = np.random.multivariate_normal([170, 70], [[20, 10],
                                                         [10, 20]], 30).T
        # Introduce two outliers
        x[10], y[10] = 160, 100
        x[8], y[8] = 165, 90
>       plot_skipped_corr(x, y, xlabel='Height', ylabel='Weight')
self       = <pingouin.tests.test_plotting.TestPlotting testMethod=test_plot_skipped_corr>
x          = array([171.97449703, 172.27220636, 168.54818478, 180.35756609,
       167.03514041, 172.84109045, 165.65250111, 172.69...10403, 159.81110951,
       161.2047311 , 177.33477196, 165.03115412, 167.49397415,
       162.62626418, 161.81616046])
y          = array([ 76.43476146,  65.53585162,  75.9336335 ,  78.4394105 ,
        63.15895949,  72.41753907,  62.79524452,  70.74...19645,  61.65770883,
        71.2140124 ,  72.68916985,  61.46210907,  72.27610054,
        70.47435378,  66.59862987])
pingouin/tests/test_plotting.py:37: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pingouin/plotting.py:260: in plot_skipped_corr
    sns.regplot(x[~outliers], y[~outliers], ax=ax1, color='darkcyan')
        _          = 0.006580253760153422
        ax1        = <matplotlib.axes._subplots.AxesSubplot object at 0xa3d0ca90>
        ax2        = <matplotlib.axes._subplots.AxesSubplot object at 0xa3b1bd30>
        ax3        = <matplotlib.axes._subplots.AxesSubplot object at 0xa3b35d78>
        compute_bootci = <function compute_bootci at 0xaaf72df0>
        fig        = <Figure size 1200x420 with 3 Axes>
        n_boot     = 2000
        outliers   = array([False, False, False, False, False, False, False, False,  True,
       False,  True, False, False, False, False, False, False, False,
       False, False, False, False, False, False, False, False, False,
       False, False, False])
        p          = 0.00432031931462259
        pearson_ci = array([0.16, 0.73])
        pearson_dist = array([0.44350053, 0.67059217, 0.5716395 , ..., 0.44427361, 0.62297048,
       0.52282334])
        pearsonr   = <function pearsonr at 0xab14dc88>
        r          = 0.5227148330596606
        r_pearson  = 0.5012714204779946
        seed       = None
        skipped    = <function skipped at 0xaaf9ffa0>
        spearman_ci = array([0.2 , 0.76])
        spearman_dist = array([0.66511117, 0.55287009, 0.6399228 , ..., 0.49890231, 0.70547757,
       0.41179713])
        x          = array([171.97449703, 172.27220636, 168.54818478, 180.35756609,
       167.03514041, 172.84109045, 165.65250111, 172.69...10403, 159.81110951,
       161.2047311 , 177.33477196, 165.03115412, 167.49397415,
       162.62626418, 161.81616046])
        xlabel     = 'Height'
        y          = array([ 76.43476146,  65.53585162,  75.9336335 ,  78.4394105 ,
        63.15895949,  72.41753907,  62.79524452,  70.74...19645,  61.65770883,
        71.2140124 ,  72.68916985,  61.46210907,  72.27610054,
        70.47435378,  66.59862987])
        ylabel     = 'Weight'
/usr/lib/python3.9/site-packages/seaborn/regression.py:818: in regplot
    plotter.plot(ax, scatter_kws, line_kws)
        ax         = <matplotlib.axes._subplots.AxesSubplot object at 0xa3d0ca90>
        ci         = 95
        color      = 'darkcyan'
        data       = None
        dropna     = True
        fit_reg    = True
        label      = None
        line_kws   = {'color': '#008b8b'}
        logistic   = False
        logx       = False
        lowess     = False
        marker     = 'o'
        n_boot     = 1000
        order      = 1
        plotter    = <seaborn.regression._RegressionPlotter object at 0xa3d0ca48>
        robust     = False
        scatter    = True
        scatter_kws = {'alpha': 0.8, 'color': '#008b8b', 'label': None, 'linewidths': 1.0, ...}
        seed       = None
        truncate   = True
        units      = None
        x          = array([171.97449703, 172.27220636, 168.54818478, 180.35756609,
       167.03514041, 172.84109045, 165.65250111, 172.69...168.71510403, 159.81110951, 161.2047311 , 177.33477196,
       165.03115412, 167.49397415, 162.62626418, 161.81616046])
        x_bins     = None
        x_ci       = 'ci'
        x_estimator = None
        x_jitter   = None
        x_partial  = None
        y          = array([76.43476146, 65.53585162, 75.9336335 , 78.4394105 , 63.15895949,
       72.41753907, 62.79524452, 70.74829576, ...
       68.66219645, 61.65770883, 71.2140124 , 72.68916985, 61.46210907,
       72.27610054, 70.47435378, 66.59862987])
        y_jitter   = None
        y_partial  = None
/usr/lib/python3.9/site-packages/seaborn/regression.py:365: in plot
    self.lineplot(ax, line_kws)
        ax         = <matplotlib.axes._subplots.AxesSubplot object at 0xa3d0ca90>
        color      = '#008b8b'
        line_kws   = {'color': '#008b8b'}
        scatter_kws = {'alpha': 0.8, 'color': '#008b8b', 'label': None, 'linewidths': 1.0, ...}
        self       = <seaborn.regression._RegressionPlotter object at 0xa3d0ca48>
/usr/lib/python3.9/site-packages/seaborn/regression.py:408: in lineplot
    grid, yhat, err_bands = self.fit_regression(ax)
        ax         = <matplotlib.axes._subplots.AxesSubplot object at 0xa3d0ca90>
        kws        = {'color': '#008b8b'}
        self       = <seaborn.regression._RegressionPlotter object at 0xa3d0ca48>
/usr/lib/python3.9/site-packages/seaborn/regression.py:216: in fit_regression
    yhat, yhat_boots = self.fit_fast(grid)
        ax         = <matplotlib.axes._subplots.AxesSubplot object at 0xa3d0ca90>
        ci         = 95
        grid       = array([159.81110951, 160.01864947, 160.22618944, 160.4337294 ,
       160.64126937, 160.84880934, 161.0563493 , 161.26...178.90478633, 179.1123263 , 179.31986626, 179.52740623,
       179.73494619, 179.94248616, 180.15002613, 180.35756609])
        self       = <seaborn.regression._RegressionPlotter object at 0xa3d0ca48>
        x_max      = 180.35756609077913
        x_min      = 159.8111095077914
        x_range    = None
/usr/lib/python3.9/site-packages/seaborn/regression.py:237: in fit_fast
    beta_boots = algo.bootstrap(X, y,
        X          = array([[  1.        , 171.97449703],
       [  1.        , 172.27220636],
       [  1.        , 168.54818478],
       ...15412],
       [  1.        , 167.49397415],
       [  1.        , 162.62626418],
       [  1.        , 161.81616046]])
        grid       = array([[  1.        , 159.81110951],
       [  1.        , 160.01864947],
       [  1.        , 160.22618944],
       ...94619],
       [  1.        , 179.94248616],
       [  1.        , 180.15002613],
       [  1.        , 180.35756609]])
        reg_func   = <function _RegressionPlotter.fit_fast.<locals>.reg_func at 0xa3ad2c88>
        self       = <seaborn.regression._RegressionPlotter object at 0xa3d0ca48>
        y          = array([76.43476146, 65.53585162, 75.9336335 , 78.4394105 , 63.15895949,
       72.41753907, 62.79524452, 70.74829576, ...
       68.66219645, 61.65770883, 71.2140124 , 72.68916985, 61.46210907,
       72.27610054, 70.47435378, 66.59862987])
        yhat       = array([65.16799299, 65.26081034, 65.35362769, 65.44644504, 65.53926239,
       65.63207974, 65.72489709, 65.81771444, ...437183, 73.70718918, 73.80000653, 73.89282388,
       73.98564123, 74.07845858, 74.17127593, 74.26409328, 74.35691063])
/usr/lib/python3.9/site-packages/seaborn/algorithms.py:85: in bootstrap
    sample = [a.take(resampler, axis=0) for a in args]
        args       = [array([[  1.        , 171.97449703],
       [  1.        , 172.27220636],
       [  1.        , 168.54818478],
      ...       68.66219645, 61.65770883, 71.2140124 , 72.68916985, 61.46210907,
       72.27610054, 70.47435378, 66.59862987])]
        axis       = None
        boot_dist  = []
        f          = <function _RegressionPlotter.fit_fast.<locals>.reg_func at 0xa3ad2c88>
        func       = <function _RegressionPlotter.fit_fast.<locals>.reg_func at 0xa3ad2c88>
        func_kwargs = {}
        i          = 0
        integers   = <built-in method integers of numpy.random._generator.Generator object at 0xa3f313e8>
        kwargs     = {'func': <function _RegressionPlotter.fit_fast.<locals>.reg_func at 0xa3ad2c88>, 'n_boot': 1000, 'seed': None, 'units': None}
        n          = 28
        n_boot     = 1000
        random_seed = None
        resampler  = array([16, 18,  3,  5, 16,  1, 15, 17, 12,  4, 10,  7, 10, 20, 22, 22,  3,
        1, 21,  3, 19,  5, 11,  6,  0, 12,  1, 20], dtype=int64)
        rng        = Generator(PCG64) at 0xA3F313E8
        seed       = None
        units      = None
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.0 = <list_iterator object at 0xa3ad7598>
>   sample = [a.take(resampler, axis=0) for a in args]
E   TypeError: Cannot cast array data from dtype('int64') to dtype('int32') according to the rule 'safe'
.0         = <list_iterator object at 0xa3ad7598>
a          = array([[  1.        , 171.97449703],
       [  1.        , 172.27220636],
       [  1.        , 168.54818478],
       ...15412],
       [  1.        , 167.49397415],
       [  1.        , 162.62626418],
       [  1.        , 161.81616046]])
resampler  = array([16, 18,  3,  5, 16,  1, 15, 17, 12,  4, 10,  7, 10, 20, 22, 22,  3,
        1, 21,  3, 19,  5, 11,  6,  0, 12,  1, 20], dtype=int64)
/usr/lib/python3.9/site-packages/seaborn/algorithms.py:85: TypeError
=============================== warnings summary ===============================
pingouin/external/tabulate.py:410
  /builddir/build/BUILD/pingouin-0.3.3/pingouin/external/tabulate.py:410: DeprecationWarning: invalid escape sequence \[
    _invisible_codes_bytes = re.compile(b"\x1b\[\d+[;\d]*m|\x1b\[\d*\;\d*\;\d*m")
pingouin/plotting.py:1114
  /builddir/build/BUILD/pingouin-0.3.3/pingouin/plotting.py:1114: DeprecationWarning: invalid escape sequence \p
    ax.text(-1.3, 0, '$\pi$', verticalalignment='center')
pingouin/plotting.py:1115
  /builddir/build/BUILD/pingouin-0.3.3/pingouin/plotting.py:1115: DeprecationWarning: invalid escape sequence \p
    ax.text(0, 1.2, '$+\pi/2$', horizontalalignment='center')
pingouin/plotting.py:1116
  /builddir/build/BUILD/pingouin-0.3.3/pingouin/plotting.py:1116: DeprecationWarning: invalid escape sequence \p
    ax.text(0, -1.3, '$-\pi/2$', horizontalalignment='center')
/usr/lib/python3.9/site-packages/outdated/utils.py:14
  /usr/lib/python3.9/site-packages/outdated/utils.py:14: OutdatedCheckFailedWarning: Failed to check for latest version of package.
  Set the environment variable OUTDATED_RAISE_EXCEPTION=1 for a full traceback.
  Set the environment variable OUTDATED_IGNORE=1 to disable these warnings.
    return warn(
pingouin/tests/test_correlation.py: 46 tests with warnings
pingouin/tests/test_distribution.py: 48 tests with warnings
pingouin/tests/test_nonparametric.py: 4 tests with warnings
pingouin/tests/test_pairwise.py: 604 tests with warnings
pingouin/tests/test_pandas.py: 37 tests with warnings
pingouin/tests/test_parametric.py: 76 tests with warnings
pingouin/tests/test_plotting.py: 6 tests with warnings
pingouin/tests/test_regression.py: 114 tests with warnings
pingouin/tests/test_utils.py: 34 tests with warnings
  /builddir/build/BUILD/pingouin-0.3.3/pingouin/utils.py:303: DeprecationWarning: NotImplemented should not be used in a boolean context
    x = list(filter(None.__ne__, x))
pingouin/tests/test_correlation.py::TestCorrelation::test_partial_corr
  /builddir/build/BUILD/pingouin-0.3.3/pingouin/utils.py:305: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
    x_is_iter = isinstance(x, collections.Iterable)
pingouin/tests/test_equivalence.py::TestEquivalence::test_tost
  /builddir/build/BUILD/pingouin-0.3.3/pingouin/bayesian.py:151: RuntimeWarning: invalid value encountered in double_scalars
    bf10 = 1 / ((1 + t**2 / df)**(-(df + 1) / 2) / integr)
pingouin/tests/test_equivalence.py::TestEquivalence::test_tost
  /builddir/build/BUILD/pingouin-0.3.3/pingouin/bayesian.py:151: RuntimeWarning: divide by zero encountered in double_scalars
    bf10 = 1 / ((1 + t**2 / df)**(-(df + 1) / 2) / integr)
pingouin/tests/test_equivalence.py::TestEquivalence::test_tost
  /builddir/build/BUILD/pingouin-0.3.3/pingouin/parametric.py:260: RuntimeWarning: invalid value encountered in multiply
    ci = np.array([tval - tcrit, tval + tcrit]) * se
pingouin/tests/test_regression.py: 55640 tests with warnings
  /usr/lib/python3.9/site-packages/scipy/optimize/lbfgsb.py:339: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
    task_str = task.tostring()
pingouin/tests/test_regression.py: 2012 tests with warnings
  /usr/lib/python3.9/site-packages/scipy/optimize/lbfgsb.py:360: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
    task_str = task.tostring().strip(b'\x00').strip()
-- Docs: https://docs.pytest.org/en/latest/warnings.html
----------- coverage: platform linux, python 3.9.0-beta-1 ------------
Name                        Stmts   Miss Branch BrPart  Cover   Missing
-----------------------------------------------------------------------
pingouin/__init__.py           21      0      0      0   100%
pingouin/bayesian.py           75      0     20      0   100%
pingouin/circular.py           83      0     10      0   100%
pingouin/contingency.py        80      0     40      1    99%   351->354
pingouin/correlation.py       267      3     86      3    98%   83->82, 449->453, 453-454, 471->474, 474
pingouin/distribution.py      170      0     56      0   100%
pingouin/effsize.py           174      2     82      2    98%   544->exit, 694->696, 696-697
pingouin/equivalence.py        13      0      0      0   100%
pingouin/multicomp.py          80      0     14      0   100%
pingouin/multivariate.py       76      0     14      2    98%   87->93, 204->212
pingouin/nonparametric.py     148      1     26      1    99%   611->612, 612
pingouin/pairwise.py          320      0    136      0   100%
pingouin/parametric.py        457      0    112      0   100%
pingouin/plotting.py          329     26     84      6    91%   261-299, 466->470, 627->631, 830->831, 831, 857->858, 858, 961->962, 962, 990->991, 991
pingouin/power.py             270      0    124      0   100%
pingouin/regression.py        290      0    108      0   100%
pingouin/reliability.py        84      0     17      0   100%
pingouin/utils.py             133      1     63      2    98%   163->175, 306->315, 315
-----------------------------------------------------------------------
TOTAL                        3070     33    992     17    99%
========================== slowest 10 test durations ===========================
57.96s call     pingouin/tests/test_effsize.py::TestEffsize::test_compute_boot_esci
29.46s call     pingouin/tests/test_regression.py::TestRegression::test_mediation_analysis
10.72s call     pingouin/tests/test_pairwise.py::TestPairwise::test_pairwise_corr
5.81s call     pingouin/tests/test_pairwise.py::TestPairwise::test_pairwise_ttests
4.74s call     pingouin/tests/test_plotting.py::TestPlotting::test_plot_skipped_corr
3.94s call     pingouin/tests/test_pandas.py::TestParametric::test_pandas
2.32s call     pingouin/tests/test_plotting.py::TestPlotting::test_plot_paired
2.06s call     pingouin/tests/test_plotting.py::TestPlotting::test_plot_rm_corr
1.30s call     pingouin/tests/test_parametric.py::TestParametric::test_anova
1.29s call     pingouin/tests/test_parametric.py::TestParametric::test_mixed_anova
=========================== short test summary info ============================
FAILED pingouin/tests/test_plotting.py::TestPlotting::test_plot_skipped_corr
=========== 1 failed, 82 passed, 58630 warnings in 147.21s (0:02:27) ===========

The complete logs are attached:

hwinfo.txt pingouin-buildlog.txt pingouin-rootlog.txt

The failed build was on armv7l.

raphaelvallat commented 4 years ago

Hi @sanjayankur31 !

Thanks for opening the issue. I am aware of the test failure, which is caused by Seaborn and not Pingouin (see https://github.com/mwaskom/seaborn/pull/1952). Can you try installing the latest version of seaborn (April 2020) and let me know if you have the same error?

Thanks Raphael

sanjayankur31 commented 4 years ago

Thanks @raphaelvallat !

I've filed a bug asking the seaborn maintainer in Fedora to update to the new release now, so that should fix the failing test for us there. I'll leave this open as a reminder to myself if that's OK?

https://bugzilla.redhat.com/show_bug.cgi?id=1844635

sanjayankur31 commented 4 years ago

Seaborn was updated, and pingouin now builds fine in Fedora 33. Thanks very much! Closing.