internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: statsmodels/statsmodels

Issue:
Series no longer inherits from ndarray
Series no longer inherit from ndarrays. We should add this fix into the maintenance branch.

https://github.com/pydata/pandas/pull/3482#issuecomment-22470169



Discussion:
Sounds pretty good if this is the only change that we have to make.

reproduced here

```
diff --git a/statsmodels/tools/tools.py b/statsmodels/tools/tools.py
index 85832d9..41c382b 100644
--- a/statsmodels/tools/tools.py
+++ b/statsmodels/tools/tools.py
@@ -231,13 +231,11 @@ def categorical(data, col=None, dictnames=False, drop=False, ):

 def _series_add_constant(data, prepend):
     const = np.ones_like(data)
-    const.name = 'const'
     if not prepend:
-        results = DataFrame([data, const]).T
-        results.columns = [data.name, 'const']
+        columns = [data.name,'const']
     else:
-        results = DataFrame([const, data]).T
-        results.columns = ['const', data.name]
+        columns = ['const',data.name]
+    results = DataFrame({ data.name : data, 'const' : const },columns=columns)
     return results

 def _dataframe_add_constant(data, prepend):
```


Resolving patch:
diff --git a/statsmodels/tools/tools.py b/statsmodels/tools/tools.py
--- a/statsmodels/tools/tools.py
+++ b/statsmodels/tools/tools.py
@@ -231,13 +231,11 @@ def categorical(data, col=None, dictnames=False, drop=False, ):
 
 def _series_add_constant(data, prepend):
     const = np.ones_like(data)
-    const.name = 'const'
     if not prepend:
-        results = DataFrame([data, const]).T
-        results.columns = [data.name, 'const']
+        columns = [data.name, 'const']
     else:
-        results = DataFrame([const, data]).T
-        results.columns = ['const', data.name]
+        columns = ['const', data.name]
+    results = DataFrame({data.name : data, 'const' : const}, columns=columns)
     return results
 
 def _dataframe_add_constant(data, prepend):


Test patch:
Repository: statsmodels/statsmodels

Issue:
update nbconvert to IPython 1.0
At some point update the nbconvert stuff to IPython 1.0. It's super fragile right now. Ie., it depends on being on a several months old nbconvert commit to work. The standalone repo is now defunct.



Discussion:

Resolving patch:
diff --git a/tools/nbgenerate.py b/tools/nbgenerate.py
--- a/tools/nbgenerate.py
+++ b/tools/nbgenerate.py
@@ -31,20 +31,11 @@
 
 from IPython.config import Config
 try:
-    from nbconvert.converters.template import ConverterTemplate
-    from nbconvert.converters.rst import ConverterRST
+    from IPython.nbconvert.exporters import HTMLExporter
 except ImportError:
-    if os.path.exists("/home/skipper/src/nbconvert"):
-        if not os.path.exists(os.path.join(cur_dir, "nbconvert")):
-            os.symlink("/home/skipper/src/nbconvert",
-               os.path.join(cur_dir, "nbconvert"))
-        from nbconvert.converters.template import ConverterTemplate
-        from nbconvert.converters.rst import ConverterRST
-    else:
-        from warnings import warn
-        warn("Notebook examples not built. Add nbconvert to path or update "
-             "paths in tools/nbgenerate.py")
-        sys.exit(0)
+    from warnings import warn
+    warn("Notebook examples not built. You need IPython 1.0.")
+    sys.exit(0)
 
 import hash_funcs
 
@@ -110,7 +101,7 @@ def run_cell(self, shell, iopub, cell, exec_count):
         outs = []
         shell.execute(cell.input)
         # hard-coded timeout, problem?
-        shell.get_msg(timeout=20)
+        shell.get_msg(timeout=90)
         cell.prompt_number = exec_count # msg["content"]["execution_count"]
 
         while True:
@@ -212,17 +203,18 @@ def nb2html(nb):
     Cribbed from nbviewer
     """
     config = Config()
-    config.ConverterTemplate.template_file = 'basichtml'
+    config.HTMLExporter.template_file = 'basic'
     config.NbconvertApp.fileext = "html"
     config.CSSHtmlHeaderTransformer.enabled = False
 
-    C = ConverterTemplate(config=config)
-    return C.convert(nb)[0]
+    C = HTMLExporter(config=config)
+    return C.from_notebook_node(nb)[0]
 
 def nb2rst(nb, files_dir):
     """
     nb should be a NotebookNode
     """
+    #NOTE: This does not currently work. Needs to be update to IPython 1.0.
     config = Config()
     C = ConverterRST(config=config)
     # bastardize how this is supposed to be called


Test patch:
Repository: statsmodels/statsmodels

Issue:
tsa models fail on PeriodIndex with pandas 
This should be fixed asap. 



Discussion:

Resolving patch:
diff --git a/statsmodels/tsa/base/datetools.py b/statsmodels/tsa/base/datetools.py
--- a/statsmodels/tsa/base/datetools.py
+++ b/statsmodels/tsa/base/datetools.py
@@ -284,6 +284,8 @@ def _add_datetimes(dates):
     return reduce(lambda x, y: y+x, dates)
 
 def _infer_freq(dates):
+    if hasattr(dates, "freqstr"):
+        return dates.freqstr
     try:
         from pandas.tseries.api import infer_freq
         freq = infer_freq(dates)
diff --git a/statsmodels/tsa/base/tsa_model.py b/statsmodels/tsa/base/tsa_model.py
--- a/statsmodels/tsa/base/tsa_model.py
+++ b/statsmodels/tsa/base/tsa_model.py
@@ -6,6 +6,10 @@
 from pandas import Index
 from pandas import datetools as pandas_datetools
 import datetime
+try:
+    from pandas import Period
+except ImportError: # not sure what version this was added
+    Period = datetime.datetime # HACK
 
 _freq_to_pandas = datetools._freq_to_pandas
 
@@ -45,7 +49,7 @@ def _init_dates(self, dates, freq):
             dates = self.data.row_labels
 
         if dates is not None:
-            if (not isinstance(dates[0], datetime.datetime) and
+            if (not isinstance(dates[0], (datetime.datetime, Period)) and
                     isinstance(self.data, data.PandasData)):
                 raise ValueError("Given a pandas object and the index does "
                                  "not contain dates")


Test patch:
diff --git a/statsmodels/tsa/base/tests/test_base.py b/statsmodels/tsa/base/tests/test_base.py
--- a/statsmodels/tsa/base/tests/test_base.py
+++ b/statsmodels/tsa/base/tests/test_base.py
@@ -78,3 +78,15 @@ def test_keyerror_start_date():
         model = TimeSeriesModel(series)
 
     npt.assert_raises(ValueError, model._get_predict_start, "1970-4-30")
+
+def test_period_index():
+    # test 1285
+    if _pandas_08x:
+        from pandas import PeriodIndex, TimeSeries
+        dates = PeriodIndex(start="1/1/1990", periods=20, freq="M")
+        x = np.arange(1, 21.)
+
+        model = TimeSeriesModel(Series(x, index=dates))
+        npt.assert_(model.data.freq == "M")
+        model = TimeSeriesModel(TimeSeries(x, index=dates))
+        npt.assert_(model.data.freq == "M")
diff --git a/statsmodels/tsa/base/tests/test_datetools.py b/statsmodels/tsa/base/tests/test_datetools.py
--- a/statsmodels/tsa/base/tests/test_datetools.py
+++ b/statsmodels/tsa/base/tests/test_datetools.py
@@ -155,3 +155,10 @@ def test_infer_freq():
     assert _infer_freq(m) == 'M'
     assert _infer_freq(d[:3]) == 'D'
     assert _infer_freq(m[:3]) == 'M'
+
+def test_period_index():
+    # tests 1285
+    if _pandas_08x:
+        from pandas import PeriodIndex
+        dates = PeriodIndex(start="1/1/1990", periods=20, freq="M")
+        npt.assert_(_infer_freq(dates) == "M")
Repository: statsmodels/statsmodels

Issue:
Bug in ARIMA forecasting when start is int len(endog) and dates are given
Fix and test coming shortly.



Discussion:

Resolving patch:
diff --git a/statsmodels/tsa/base/tsa_model.py b/statsmodels/tsa/base/tsa_model.py
--- a/statsmodels/tsa/base/tsa_model.py
+++ b/statsmodels/tsa/base/tsa_model.py
@@ -106,7 +106,7 @@ def _set_predict_start_date(self, start):
             raise ValueError("Start must be <= len(endog)")
         if start == len(dates):
             self.data.predict_start = datetools._date_from_idx(dates[-1],
-                                                    start, self.data.freq)
+                                                    1, self.data.freq)
         elif start < len(dates):
             self.data.predict_start = dates[start]
         else:


Test patch:
diff --git a/statsmodels/tsa/tests/test_arima.py b/statsmodels/tsa/tests/test_arima.py
--- a/statsmodels/tsa/tests/test_arima.py
+++ b/statsmodels/tsa/tests/test_arima.py
@@ -1897,6 +1897,18 @@ def test_arima00():
     assert_raises(ValueError, ARIMA, y, (0,1,0))
     assert_raises(ValueError, ARIMA, y, (0,0,0))
 
+def test_arima_dates_startatend():
+    # bug
+    np.random.seed(18)
+    x = pandas.TimeSeries(np.random.random(36),
+                          index=pandas.DatetimeIndex(start='1/1/1990',
+                                                     periods=36, freq='M'))
+    res = ARIMA(x, (1, 0, 0)).fit(disp=0)
+    pred = res.predict(start=len(x), end=len(x))
+    assert_(pred.index[0] == x.index.shift(1)[-1])
+    fc = res.forecast()[0]
+    assert_almost_equal(pred.values[0], fc)
+
 if __name__ == "__main__":
     import nose
     nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb'], exit=False)
Repository: statsmodels/statsmodels

Issue:
ARMA doesn't pass missing keyword up to TimeSeriesModel



Discussion:

Resolving patch:
diff --git a/statsmodels/tsa/arima_model.py b/statsmodels/tsa/arima_model.py
--- a/statsmodels/tsa/arima_model.py
+++ b/statsmodels/tsa/arima_model.py
@@ -361,7 +361,7 @@ class ARMA(tsbase.TimeSeriesModel):
 
     def __init__(self, endog, order=None, exog=None, dates=None, freq=None,
                         missing='none'):
-        super(ARMA, self).__init__(endog, exog, dates, freq)
+        super(ARMA, self).__init__(endog, exog, dates, freq, missing=missing)
         exog = self.data.exog # get it after it's gone through processing
         if order is None:
             import warnings


Test patch:
diff --git a/statsmodels/tsa/tests/test_arima.py b/statsmodels/tsa/tests/test_arima.py
--- a/statsmodels/tsa/tests/test_arima.py
+++ b/statsmodels/tsa/tests/test_arima.py
@@ -1909,6 +1909,13 @@ def test_arima_dates_startatend():
     fc = res.forecast()[0]
     assert_almost_equal(pred.values[0], fc)
 
+def test_arma_missing():
+    from statsmodels.base.data import MissingDataError
+    # bug 1343
+    y = np.random.random(40)
+    y[-1] = np.nan
+    assert_raises(MissingDataError, ARMA, y, (1, 0), missing='raise')
+
 if __name__ == "__main__":
     import nose
     nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb'], exit=False)
Repository: statsmodels/statsmodels

Issue:
move graphics.tsa to tsa.graphics
Makes more sense to me to keep the tsa stuff under the tsa namespace. Might need to deprecate functions that aren't new. 



Discussion:

Resolving patch:
diff --git a/statsmodels/tsa/api.py b/statsmodels/tsa/api.py
--- a/statsmodels/tsa/api.py
+++ b/statsmodels/tsa/api.py
@@ -11,3 +11,4 @@
 import stattools
 from .stattools import *
 from .base import datetools
+from ..graphics import tsaplots as graphics


Test patch:
Repository: statsmodels/statsmodels

Issue:
Actually use dangling libraries=['m'] in setup.py
On line 380:

```
libraries = ['m'] if 'win32' not in sys.platform else []
```

doesn't get used.

I'm not sure how necessary the `libraries = ['m']` inclusion is. What linux distributions don't include libc math? See http://docs.cython.org/src/tutorial/external.html#dynamic-linking for details.



Discussion:
[![Coverage Status](https://coveralls.io/builds/225681/badge)](https://coveralls.io/builds/225681)

Coverage remained the same when pulling **edf56469672f55cd02ade24b178ae626dc460861 on ariddell:patch-1** into **16365edb9ecf0271bd59e60136722981a500648c on statsmodels:master**.

Ubuntu and Debian don't seem to need it.
TravisCI uses just the setup.py, but I don't know if python-xy's Ubuntu testing or Yaroslav's Debian testing changed the libraries.

@yarikoptic   Do you have more information on POSIX systems?

If it doesn't hurt we could as well use it, even if the library is linked automatically. ?

FWIW -- the question should be either you use any of the 'm' symbols directly in your code?  if not -- then do not bother adding.

Used here:

```
statsmodels/nonparametric/_smoothers_lowess.pyx
21:from libc.math cimport fabs
```

On Tue, 24 Sep 2013, Allen Riddell wrote:

>    Used here:
> 
>  statsmodels/nonparametric/_smoothers_lowess.pyx
>  21:from libc.math cimport fabs

;) not "used" but rather "imported" seems to me:

$> grep fabs ./statsmodels/nonparametric/_smoothers_lowess.{pyx,c}
./statsmodels/nonparametric/_smoothers_lowess.pyx:from libc.math cimport fabs

so you probably should just remove that line ;)

## 

Yaroslav O. Halchenko, Ph.D.
http://neuro.debian.net http://www.pymvpa.org http://www.fail2ban.org
Senior Research Associate,     Psychological and Brain Sciences Dept.
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik

IIRC libc.math was used for fmax, but we had to inline that one because it wasn't available on Windows.
lowess use np.abs instead of fmax, I guess, because it uses the vectorized version.

How about leaving this PR open, until we run into a problem with this? 
I expect we get more cython code and it will eventually use use libc.math.
Then, at least we know right away what to fix.

In either case, Thanks @ariddell  for finding this inconsistency in setup.py.


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -379,7 +379,8 @@ def srcpath(name=None, suffix='.pyx', subdir='src'):
 common_include = []
 
 # some linux distros require it
-libraries = ['m'] if 'win32' not in sys.platform else []
+#NOTE: we are not currently using this but add it to Extension, if needed.
+# libraries = ['m'] if 'win32' not in sys.platform else []
 
 ext_data = dict(
         kalman_loglike = {"pyxfile" : "tsa/kalmanf/kalman_loglike",


Test patch:
Repository: statsmodels/statsmodels

Issue:
ipython_directive doesn't work with ipython master
I think it's time to just use the one provided by IPython, so we don't have to maintain this anymore. This means IPython becomes a dependency for doc builds. 



Discussion:

Resolving patch:
diff --git a/docs/source/conf.py b/docs/source/conf.py
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -32,8 +32,8 @@
               'sphinx.ext.inheritance_diagram',
               'matplotlib.sphinxext.plot_directive',
               'matplotlib.sphinxext.only_directives',
-              'ipython_console_highlighting',
-              'ipython_directive',
+              'IPython.sphinxext.ipython_console_highlighting',
+              'IPython.sphinxext.ipython_directive',
               'numpy_ext.numpydoc',
               'github' # for GitHub links
               ]


Test patch:
Repository: statsmodels/statsmodels

Issue:
statsmodels.stats.proportion.proportions_chisquare_allpairs has hardcoded value
This should be a quick fix:

```
all_pairs = zip(*np.triu_indices(4, 1))
```

should be

```
all_pairs = zip(*np.triu_indices(len(count), 1))
```



Discussion:
Thanks @mtrbean 

clearly a bug, there is only one test case and that has 4 values.

aside: the `smprop.proportions_chisquare_pairscontrol` test case doesn't check that the multiple testing p-value correction has the correct values, only raw p-values have a test.

`proportions_chisquare_allpairs` also has verified numbers for 'holm' corrected p-values


Resolving patch:
diff --git a/statsmodels/stats/proportion.py b/statsmodels/stats/proportion.py
--- a/statsmodels/stats/proportion.py
+++ b/statsmodels/stats/proportion.py
@@ -730,7 +730,7 @@ def proportions_chisquare_allpairs(count, nobs, multitest_method='hs'):
     Yates continuity correction is not available.
     '''
     #all_pairs = lmap(list, lzip(*np.triu_indices(4, 1)))
-    all_pairs = lzip(*np.triu_indices(4, 1))
+    all_pairs = lzip(*np.triu_indices(len(count), 1))
     pvals = [proportions_chisquare(count[list(pair)], nobs[list(pair)])[1]
                for pair in all_pairs]
     return AllPairsResults(pvals, all_pairs, multitest_method=multitest_method)


Test patch:
diff --git a/statsmodels/stats/tests/test_proportion.py b/statsmodels/stats/tests/test_proportion.py
--- a/statsmodels/stats/tests/test_proportion.py
+++ b/statsmodels/stats/tests/test_proportion.py
@@ -82,6 +82,17 @@ def test_pairwiseproptest(self):
         assert_almost_equal(pptd.pvals_raw, ppt.pvals_raw[:len(self.nobs) - 1],
                             decimal=13)
 
+
+    def test_number_pairs_1493(self):
+        ppt = smprop.proportions_chisquare_allpairs(self.n_success[:3],
+                                                    self.nobs[:3],
+                                                    multitest_method=None)
+
+        assert_equal(len(ppt.pvals_raw), 3)
+        idx = [0, 1, 3]
+        assert_almost_equal(ppt.pvals_raw, self.res_ppt_pvals_raw[idx])
+
+
 class TestProportion(CheckProportionMixin):
     def setup(self):
         self.n_success = np.array([ 73,  90, 114,  75])
Repository: statsmodels/statsmodels

Issue:
docstring for regression.linear_model.RegressionModel.predict() does not match implementation
Docstring says 'params' is optional if the model has not been fit, but the implementation does not allow 'params' to be absent.



Discussion:
Thanks, that statement is outdated by a few versions.
(we dropped attaching results to the model instance because of circular reference)
the model predict always requires params, but x/exog is optional.


Resolving patch:
diff --git a/statsmodels/regression/linear_model.py b/statsmodels/regression/linear_model.py
--- a/statsmodels/regression/linear_model.py
+++ b/statsmodels/regression/linear_model.py
@@ -238,7 +238,7 @@ def predict(self, params, exog=None):
 
         Parameters
         ----------
-        params : array-like, optional after fit has been called
+        params : array-like
             Parameters of a linear model
         exog : array-like, optional.
             Design / exogenous data. Model exog is used if None.


Test patch:
Repository: statsmodels/statsmodels

Issue:
Contrast Results after t_test summary broken for 1 parameter
Check what ndim we should have in result of t_test, f_test, ...
f_test returns a single value as ndim=2
pvalues for t_test doesn't have the same ndim, shape as the tvalues

```
>>> import numpy as np
>>> import statsmodels.api as sm
>>> nobs=100
>>> x = 1 + np.random.randn(nobs)
>>> w = np.random.chisquare(5, size=nobs)
>>> res = sm.WLS(x, np.ones(nobs), weights=w).fit()


>>> tt = res.t_test(r_matrix=[1], q_matrix=[1])
>>> print tt.summary()
Traceback (most recent call last):
  File "<pyshell#42>", line 1, in <module>
    print tt.summary()
  File "e:\josef\eclipsegworkspace\statsmodels-git\statsmodels-all-new2_py27\statsmodels\statsmodels\stats\contrast.py", line 101, in summary
    title=title)
  File "e:\josef\eclipsegworkspace\statsmodels-git\statsmodels-all-new2_py27\statsmodels\statsmodels\iolib\summary.py", line 498, in summary_params
    ["%#6.3f" % (pvalues[i]) for i in exog_idx],
IndexError: 0-d arrays can't be indexed
```



Discussion:

Resolving patch:
diff --git a/statsmodels/stats/contrast.py b/statsmodels/stats/contrast.py
--- a/statsmodels/stats/contrast.py
+++ b/statsmodels/stats/contrast.py
@@ -97,8 +97,9 @@ def summary(self, xname=None, alpha=0.05, title=None):
             if xname is None:
                 xname = ['c%d'%ii for ii in range(len(self.effect))]
             from statsmodels.iolib.summary import summary_params
+            pvalues = np.atleast_1d(self.pvalue)
             summ = summary_params((self, self.effect, self.sd, self.statistic,
-                                   self.pvalue, self.conf_int(alpha)),
+                                   pvalues, self.conf_int(alpha)),
                                   yname=yname, xname=xname, use_t=use_t,
                                   title=title)
             return summ


Test patch:
diff --git a/statsmodels/base/tests/test_generic_methods.py b/statsmodels/base/tests/test_generic_methods.py
--- a/statsmodels/base/tests/test_generic_methods.py
+++ b/statsmodels/base/tests/test_generic_methods.py
@@ -66,6 +66,10 @@ def test_ttest_tvalues(self):
         # move this to test_attributes ?
         assert_(hasattr(res, 'use_t'))
 
+        tt = res.t_test(mat[0])
+        tt.summary()   # smoke test for #1323
+        assert_allclose(tt.pvalue, res.pvalues[0], rtol=5e-10)
+
 
     def test_ftest_pvalues(self):
         res = self.results
Repository: statsmodels/statsmodels

Issue:
ENH/Bug cov_params, generalize, avoid ValueError
insufficient refactoring when `cov_params_default` was added

```
        if cov_p is None and self.normalized_cov_params is None:
            raise ValueError('need covariance of parameters for computing '
                             '(unnormalized) covariances')
```

another improvement: 
short-circuit if no arguments are given and we just want `cov_params()`. There is no need for checking all cases if all arguments are None.

I assume we don't have a subclass yet that does not define `normalized_cov_params`, so no error or failure so far.



Discussion:

Resolving patch:
diff --git a/statsmodels/base/model.py b/statsmodels/base/model.py
--- a/statsmodels/base/model.py
+++ b/statsmodels/base/model.py
@@ -927,7 +927,8 @@ def cov_params(self, r_matrix=None, column=None, scale=None, cov_p=None,
         else:
             dot_fun = np.dot
 
-        if cov_p is None and self.normalized_cov_params is None:
+        if (cov_p is None and self.normalized_cov_params is None and
+            not hasattr(self, 'cov_params_default')):
             raise ValueError('need covariance of parameters for computing '
                              '(unnormalized) covariances')
         if column is not None and (r_matrix is not None or other is not None):
@@ -937,11 +938,11 @@ def cov_params(self, r_matrix=None, column=None, scale=None, cov_p=None,
             raise ValueError('other can only be specified with r_matrix')
 
         if cov_p is None:
-            if scale is None:
-                scale = self.scale
             if hasattr(self, 'cov_params_default'):
                 cov_p = self.cov_params_default
             else:
+                if scale is None:
+                    scale = self.scale
                 cov_p = self.normalized_cov_params * scale
 
         if column is not None:


Test patch:
Repository: statsmodels/statsmodels

Issue:
Source directory problem for notebook examples
I had some trouble building the docs using 

```
make html
```

from the /docs directory. The problem seemed to come from the file 'tools/nbgenerate.py', which has the line

```
SOURCE_DIR = ("/home/skipper/statsmodels/statsmodels-skipper/examples/"
          "notebooks")
```

Obviously the first directory didn't exist for me, which caused an error. 

Current version: 0.6.0.dev-b2c35b4



Discussion:
Should be replaced by relative path, but I haven't set up nbconvert to test this

I do have nbconvert set up, but couldn't quite figure out what the relative paths should be, so I'll leave this to someone who knows what they are doing.

+1 Same issue here when trying to build docs.

PR would be welcome here.


Resolving patch:
diff --git a/tools/nbgenerate.py b/tools/nbgenerate.py
--- a/tools/nbgenerate.py
+++ b/tools/nbgenerate.py
@@ -6,7 +6,6 @@
 
 # prefer HTML over rST for now until nbconvert changes drop
 OUTPUT = "html"
-SOURCE_DIR = "/home/skipper/statsmodels/statsmodels/examples/notebooks"
 
 import os
 import io
@@ -14,6 +13,10 @@
 import time
 import shutil
 
+SOURCE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..",
+                                          "examples",
+                                          "notebooks"))
+
 from Queue import Empty
 
 try: # IPython has been refactored


Test patch: