diff options
author | Marius Bakke <mbakke@fastmail.com> | 2017-03-06 16:09:23 +0100 |
---|---|---|
committer | Marius Bakke <mbakke@fastmail.com> | 2017-03-06 23:24:11 +0100 |
commit | 6cb747769915e8ecef04fd5c5a625d535f4db1d7 (patch) | |
tree | 65cd3724f991a3dae1ba06dd5bebaaba5c267b2e | |
parent | 8e08604814d32f6f934932d5516f111bc2bb6d12 (diff) | |
download | guix-6cb747769915e8ecef04fd5c5a625d535f4db1d7.tar.gz |
gnu: python-statsmodels: Update to 0.8.0.
* gnu/packages/statistics.scm (python-statsmodels, python2-statsmodels): Update to 0.8.0. [source]: Use 'pypi-uri'. [arguments]: Add more files to matplotlib backend substitution. * gnu/packages/patches/python-statsmodels-fix-tests.patch: Drop test that fails with numpy 1.12. Remove previous contents.
-rw-r--r-- | gnu/packages/patches/python-statsmodels-fix-tests.patch | 224 | ||||
-rw-r--r-- | gnu/packages/statistics.scm | 11 |
2 files changed, 34 insertions, 201 deletions
diff --git a/gnu/packages/patches/python-statsmodels-fix-tests.patch b/gnu/packages/patches/python-statsmodels-fix-tests.patch index 3315ddbd5f..f910b4b5a5 100644 --- a/gnu/packages/patches/python-statsmodels-fix-tests.patch +++ b/gnu/packages/patches/python-statsmodels-fix-tests.patch @@ -1,196 +1,28 @@ -This patch fixes a couple of test failures introduced by changes to the pandas -package. It was extracted from this pull request: - -https://github.com/statsmodels/statsmodels/pull/2675 - - -From c9ef60a7bc4407766ab9e9f12c8a6b89013046ee Mon Sep 17 00:00:00 2001 -From: Ralf Gommers <ralf.gommers@gmail.com> -Date: Tue, 20 Oct 2015 07:34:11 +0200 -Subject: [PATCH 1/4] MAINT: fix use of old_behavior kw for numpy.correlate. - Was removed in 1.10.0 - -Numpy PR that removed it: https://github.com/numpy/numpy/pull/5991 - -Closes gh-2667. ---- - statsmodels/tsa/ar_model.py | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - -diff --git a/statsmodels/tsa/ar_model.py b/statsmodels/tsa/ar_model.py -index 087a9e0..02984bd 100644 ---- a/statsmodels/tsa/ar_model.py -+++ b/statsmodels/tsa/ar_model.py -@@ -261,10 +261,8 @@ def _presample_varcov(self, params): - - Vpinv = np.zeros((p, p), dtype=params.dtype) - for i in range(1, p1): -- Vpinv[i-1, i-1:] = np.correlate(params0, params0[:i], -- old_behavior=False)[:-1] -- Vpinv[i-1, i-1:] -= np.correlate(params0[-i:], params0, -- old_behavior=False)[:-1] -+ Vpinv[i-1, i-1:] = np.correlate(params0, params0[:i],)[:-1] -+ Vpinv[i-1, i-1:] -= np.correlate(params0[-i:], params0,)[:-1] - - Vpinv = Vpinv + Vpinv.T - np.diag(Vpinv.diagonal()) - return Vpinv - -From f1dc8979b09bc1736149993f895943b3158ee2db Mon Sep 17 00:00:00 2001 -From: Ralf Gommers <ralf.gommers@gmail.com> -Date: Wed, 21 Oct 2015 22:05:52 +0200 -Subject: [PATCH 2/4] MAINT: fix graphics module for changes in recent pandas - versions. - ---- - statsmodels/graphics/tests/test_mosaicplot.py | 2 +- - statsmodels/graphics/tests/test_tsaplots.py | 6 +++--- - statsmodels/graphics/tsaplots.py | 2 +- - 3 files changed, 5 insertions(+), 5 deletions(-) - -diff --git a/statsmodels/graphics/tests/test_mosaicplot.py b/statsmodels/graphics/tests/test_mosaicplot.py -index cb9bbbe..e41020e 100644 ---- a/statsmodels/graphics/tests/test_mosaicplot.py -+++ b/statsmodels/graphics/tests/test_mosaicplot.py -@@ -113,7 +113,7 @@ def test_mosaic(): - # sort by the marriage quality and give meaningful name - # [rate_marriage, age, yrs_married, children, - # religious, educ, occupation, occupation_husb] -- datas = datas.sort(['rate_marriage', 'religious']) -+ datas = datas.sort_values(by=['rate_marriage', 'religious']) - num_to_desc = {1: 'awful', 2: 'bad', 3: 'intermediate', - 4: 'good', 5: 'wonderful'} - datas['rate_marriage'] = datas['rate_marriage'].map(num_to_desc) -diff --git a/statsmodels/graphics/tests/test_tsaplots.py b/statsmodels/graphics/tests/test_tsaplots.py -index 511f18f..365be82 100644 ---- a/statsmodels/graphics/tests/test_tsaplots.py -+++ b/statsmodels/graphics/tests/test_tsaplots.py -@@ -1,4 +1,4 @@ --from statsmodels.compat.python import lmap, lzip, map -+from statsmodels.compat.python import lmap, map - import numpy as np - import pandas as pd - from numpy.testing import dec -@@ -51,8 +51,8 @@ def test_plot_month(): - dta = sm.datasets.elnino.load_pandas().data - dta['YEAR'] = dta.YEAR.astype(int).apply(str) - dta = dta.set_index('YEAR').T.unstack() -- dates = lmap(lambda x : pd.datetools.parse('1 '+' '.join(x)), -- dta.index.values) -+ dates = lmap(lambda x : pd.datetools.parse_time_string('1 '+' '.join(x))[0], -+ dta.index.values) - - # test dates argument - fig = month_plot(dta.values, dates=dates, ylabel='el nino') -diff --git a/statsmodels/graphics/tsaplots.py b/statsmodels/graphics/tsaplots.py -index 3d04692..94626c9 100644 ---- a/statsmodels/graphics/tsaplots.py -+++ b/statsmodels/graphics/tsaplots.py -@@ -200,7 +200,7 @@ def seasonal_plot(grouped_x, xticklabels, ylabel=None, ax=None): - ticks = [] - for season, df in grouped_x: - df = df.copy() # or sort balks for series. may be better way -- df.sort() -+ df.sort_values(inplace=True) - nobs = len(df) - x_plot = np.arange(start, start + nobs) - ticks.append(x_plot.mean()) - -From 4cfbef6af137629c6953f1f025d9cfc781874256 Mon Sep 17 00:00:00 2001 -From: Ralf Gommers <ralf.gommers@gmail.com> -Date: Wed, 21 Oct 2015 22:15:25 +0200 -Subject: [PATCH 3/4] MAINT: work around pandas breaking backwards compat for - pandas.version - ---- - setup.py | 5 ++++- - statsmodels/tools/testing.py | 6 ++---- - 2 files changed, 6 insertions(+), 5 deletions(-) - -diff --git a/setup.py b/setup.py -index 0002840..74aefb8 100644 ---- a/setup.py -+++ b/setup.py -@@ -134,7 +134,10 @@ def check_dependency_versions(min_versions): - (spversion, min_versions['scipy'])) - - try: -- from pandas.version import short_version as pversion -+ import pandas -+ #FIXME: this will break for pandas 1.0.0. Needs elaborate parsing now, -+ # due to pandas removing version.short_version -+ pversion = pandas.__version__[:6] - except ImportError: - install_requires.append('pandas') - else: -diff --git a/statsmodels/tools/testing.py b/statsmodels/tools/testing.py -index e207e44..643f79f 100644 ---- a/statsmodels/tools/testing.py -+++ b/statsmodels/tools/testing.py -@@ -16,10 +16,8 @@ def strip_rc(version): - - - def is_pandas_min_version(min_version): -- '''check whether pandas is at least min_version -- ''' -- from pandas.version import short_version as pversion -- return StrictVersion(strip_rc(pversion)) >= min_version -+ '''check whether pandas is at least min_version ''' -+ return StrictVersion((pandas.__version__[:6])) >= min_version - - - # local copies, all unchanged - -From c894c3f4882d570efb517950069d83afa9794db8 Mon Sep 17 00:00:00 2001 -From: Ralf Gommers <ralf.gommers@gmail.com> -Date: Mon, 26 Oct 2015 20:47:51 +0100 -Subject: [PATCH 4/4] BUG: fix use of Series.sort_values for older pandas. - -Some failing tests in the previous commits because older ``pandas`` versions -don't have ``Series.sort_values``. That method was only added in pandas 0.17, -in https://github.com/pydata/pandas/pull/10726 ---- - statsmodels/graphics/tests/test_mosaicplot.py | 6 +++++- - statsmodels/graphics/tsaplots.py | 6 +++++- - 2 files changed, 10 insertions(+), 2 deletions(-) - -diff --git a/statsmodels/graphics/tests/test_mosaicplot.py b/statsmodels/graphics/tests/test_mosaicplot.py -index e41020e..2a873e7 100644 ---- a/statsmodels/graphics/tests/test_mosaicplot.py -+++ b/statsmodels/graphics/tests/test_mosaicplot.py -@@ -113,7 +113,11 @@ def test_mosaic(): - # sort by the marriage quality and give meaningful name - # [rate_marriage, age, yrs_married, children, - # religious, educ, occupation, occupation_husb] -- datas = datas.sort_values(by=['rate_marriage', 'religious']) -+ if pandas.__version__ < '0.17.0': -+ datas = datas.sort(['rate_marriage', 'religious']) -+ else: -+ datas = datas.sort_values(by=['rate_marriage', 'religious']) -+ - num_to_desc = {1: 'awful', 2: 'bad', 3: 'intermediate', - 4: 'good', 5: 'wonderful'} - datas['rate_marriage'] = datas['rate_marriage'].map(num_to_desc) -diff --git a/statsmodels/graphics/tsaplots.py b/statsmodels/graphics/tsaplots.py -index 94626c9..217724f 100644 ---- a/statsmodels/graphics/tsaplots.py -+++ b/statsmodels/graphics/tsaplots.py -@@ -2,6 +2,7 @@ - - - import numpy as np -+import pandas - - from statsmodels.graphics import utils - from statsmodels.tsa.stattools import acf, pacf -@@ -200,7 +201,10 @@ def seasonal_plot(grouped_x, xticklabels, ylabel=None, ax=None): - ticks = [] - for season, df in grouped_x: - df = df.copy() # or sort balks for series. may be better way -- df.sort_values(inplace=True) -+ if pandas.__version__ < '0.17.0': -+ df.sort() -+ else: -+ df.sort_values(inplace=True) - nobs = len(df) - x_plot = np.arange(start, start + nobs) - ticks.append(x_plot.mean()) +This drops a test that fails with numpy 1.12. + +Upstream bug URL: https://github.com/statsmodels/statsmodels/issues/3541 + +--- a/statsmodels/discrete/tests/test_discrete.py 2017-03-06 15:29:19.947343331 +0000 ++++ b/statsmodels/discrete/tests/test_discrete.py 2017-03-06 15:29:37.759328845 +0000 +@@ -1329,21 +1329,6 @@ + res = mod.fit(start_params=-np.ones(4), method='newton', disp=0) + assert_(not res.mle_retvals['converged']) + +-def test_issue_339(): +- # make sure MNLogit summary works for J != K. +- data = sm.datasets.anes96.load() +- exog = data.exog +- # leave out last exog column +- exog = exog[:,:-1] +- exog = sm.add_constant(exog, prepend=True) +- res1 = sm.MNLogit(data.endog, exog).fit(method="newton", disp=0) +- # strip the header from the test +- smry = "\n".join(res1.summary().as_text().split('\n')[9:]) +- cur_dir = os.path.dirname(os.path.abspath(__file__)) +- test_case_file = os.path.join(cur_dir, 'results', 'mn_logit_summary.txt') +- test_case = open(test_case_file, 'r').read() +- np.testing.assert_equal(smry, test_case[:-1]) +- + def test_issue_341(): + data = sm.datasets.anes96.load() + exog = data.exog diff --git a/gnu/packages/statistics.scm b/gnu/packages/statistics.scm index 139ac71834..bfa4cafe1e 100644 --- a/gnu/packages/statistics.scm +++ b/gnu/packages/statistics.scm @@ -1437,15 +1437,14 @@ building design matrices.") (define-public python-statsmodels (package (name "python-statsmodels") - (version "0.6.1") + (version "0.8.0") (source (origin (method url-fetch) - (uri (string-append "https://pypi.python.org/packages/source/" - "s/statsmodels/statsmodels-" version ".tar.gz")) + (uri (pypi-uri "statsmodels" version)) (sha256 (base32 - "0xn67sqr0cc1lmlhzm71352hrb4hw7g318p5ff5q97pc98vl8kmy")) + "0j30v3932shnj9368c9jr3svkyrvfj90h2l7nxnqkbpv0svilhr6")) (patches (search-patches "python-statsmodels-fix-tests.patch")))) (build-system python-build-system) (arguments @@ -1457,7 +1456,9 @@ building design matrices.") (lambda _ ;; Set the matplotlib backend to Agg to avoid problems using the ;; GTK backend without a display. - (substitute* (find-files "statsmodels/graphics/tests" "\\.py") + (substitute* (append (find-files "statsmodels/graphics/tests" "\\.py") + '("statsmodels/tsa/vector_ar/tests/test_var.py" + "statsmodels/duration/tests/test_survfunc.py")) (("import matplotlib\\.pyplot as plt" line) (string-append "import matplotlib;matplotlib.use('Agg');" line))) |