prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Test Baxter King band-pass filter fails with scipy 0.12 beta1
  current git head 1b12824f53b1 and 0.4.3, python2.7 tested on ubuntu 13.04 amd64, haven't tried scipy 0.11 but it the test seems to work with the 0.10.1 package
  
  ```
  ======================================================================
  ERROR: Test Baxter King band-pass filter. Results are taken from Stata
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
      self.test(*self.arg)
    File "/statsmodels/statsmodels/tsa/filters/tests/test_filters.py", line 47, in test_bking1d
      Y = bkfilter(X, 6, 32, 12)
    File "/statsmodels/statsmodels/tsa/filters/bk_filter.py", line 72, in bkfilter
      return fftconvolve(bweights, X, mode='valid') # get a centered moving avg/
    File "/usr/lib/python2.7/dist-packages/scipy/signal/signaltools.py", line 204, in fftconvolve
      _check_valid_mode_shapes(s1, s2)
    File "/usr/lib/python2.7/dist-packages/scipy/signal/signaltools.py", line 64, in _check_valid_mode_shapes
      "in1 should have at least as many items as in2 in "
  ValueError: in1 should have at least as many items as in2 in every dimension for 'valid' mode.
  
  ----------------------------------------------------------------------
  ```
  
  
  </issue>
  <code>
  [start of statsmodels/tsa/filters/bk_filter.py]
  1 import numpy as np
  2 from scipy.signal import fftconvolve
  3 
  4 def bkfilter(X, low=6, high=32, K=12):
  5     """
  6     Baxter-King bandpass filter
  7 
  8     Parameters
  9     ----------
  10     X : array-like
  11         A 1 or 2d ndarray. If 2d, variables are assumed to be in columns.
  12     low : float
  13         Minimum period for oscillations, ie., Baxter and King suggest that
  14         the Burns-Mitchell U.S. business cycle has 6 for quarterly data and
  15         1.5 for annual data.
  16     high : float
  17         Maximum period for oscillations BK suggest that the U.S.
  18         business cycle has 32 for quarterly data and 8 for annual data.
  19     K : int
  20         Lead-lag length of the filter. Baxter and King propose a truncation
  21         length of 12 for quarterly data and 3 for annual data.
  22 
  23     Returns
  24     -------
  25     Y : array
  26         Cyclical component of X
  27 
  28     References
  29     ---------- ::
  30     Baxter, M. and R. G. King. "Measuring Business Cycles: Approximate
  31         Band-Pass Filters for Economic Time Series." *Review of Economics and
  32         Statistics*, 1999, 81(4), 575-593.
  33 
  34     Notes
  35     -----
  36     Returns a centered weighted moving average of the original series. Where
  37     the weights a[j] are computed ::
  38 
  39       a[j] = b[j] + theta, for j = 0, +/-1, +/-2, ... +/- K
  40       b[0] = (omega_2 - omega_1)/pi
  41       b[j] = 1/(pi*j)(sin(omega_2*j)-sin(omega_1*j), for j = +/-1, +/-2,...
  42 
  43     and theta is a normalizing constant ::
  44 
  45       theta = -sum(b)/(2K+1)
  46 
  47     Examples
  48     --------
  49     >>> import statsmodels.api as sm
  50     >>> dta = sm.datasets.macrodata.load()
  51     >>> X = dta.data['realinv']
  52     >>> Y = sm.tsa.filters.bkfilter(X, 6, 24, 12)
  53     """
  54 #TODO: change the docstring to ..math::?
  55 #TODO: allow windowing functions to correct for Gibb's Phenomenon?
  56 # adjust bweights (symmetrically) by below before demeaning
  57 # Lancosz Sigma Factors np.sinc(2*j/(2.*K+1))
  58     if low < 2:
  59         raise ValueError("low cannot be less than 2")
  60     X = np.asarray(X)
  61     omega_1 = 2.*np.pi/high # convert from freq. to periodicity
  62     omega_2 = 2.*np.pi/low
  63     bweights = np.zeros(2*K+1)
  64     bweights[K] = (omega_2 - omega_1)/np.pi # weight at zero freq.
  65     j = np.arange(1,int(K)+1)
  66     weights = 1/(np.pi*j)*(np.sin(omega_2*j)-np.sin(omega_1*j))
  67     bweights[K+j] = weights # j is an idx
  68     bweights[:K] = weights[::-1] # make symmetric weights
  69     bweights -= bweights.mean() # make sure weights sum to zero
  70     if X.ndim == 2:
  71         bweights = bweights[:,None]
  72     return fftconvolve(bweights, X, mode='valid') # get a centered moving avg/
  73                                                   # convolution
  74
  [end of statsmodels/tsa/filters/bk_filter.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/statsmodels/tsa/filters/bk_filter.py b/statsmodels/tsa/filters/bk_filter.py
  --- a/statsmodels/tsa/filters/bk_filter.py
  +++ b/statsmodels/tsa/filters/bk_filter.py
  @@ -69,5 +69,5 @@
       bweights -= bweights.mean() # make sure weights sum to zero
       if X.ndim == 2:
           bweights = bweights[:,None]
  -    return fftconvolve(bweights, X, mode='valid') # get a centered moving avg/
  +    return fftconvolve(X, bweights, mode='valid') # get a centered moving avg/
                                                     # convolution
  
verification_info: {"golden_diff": "diff --git a/statsmodels/tsa/filters/bk_filter.py b/statsmodels/tsa/filters/bk_filter.py\n--- a/statsmodels/tsa/filters/bk_filter.py\n+++ b/statsmodels/tsa/filters/bk_filter.py\n@@ -69,5 +69,5 @@\n     bweights -= bweights.mean() # make sure weights sum to zero\n     if X.ndim == 2:\n         bweights = bweights[:,None]\n-    return fftconvolve(bweights, X, mode='valid') # get a centered moving avg/\n+    return fftconvolve(X, bweights, mode='valid') # get a centered moving avg/\n                                                   # convolution\n", "issue": "Test Baxter King band-pass filter fails with scipy 0.12 beta1\ncurrent git head 1b12824f53b1 and 0.4.3, python2.7 tested on ubuntu 13.04 amd64, haven't tried scipy 0.11 but it the test seems to work with the 0.10.1 package\n\n```\n======================================================================\nERROR: Test Baxter King band-pass filter. Results are taken from Stata\n----------------------------------------------------------------------\nTraceback (most recent call last):\n  File \"/usr/lib/python2.7/dist-packages/nose/case.py\", line 197, in runTest\n    self.test(*self.arg)\n  File \"/statsmodels/statsmodels/tsa/filters/tests/test_filters.py\", line 47, in test_bking1d\n    Y = bkfilter(X, 6, 32, 12)\n  File \"/statsmodels/statsmodels/tsa/filters/bk_filter.py\", line 72, in bkfilter\n    return fftconvolve(bweights, X, mode='valid') # get a centered moving avg/\n  File \"/usr/lib/python2.7/dist-packages/scipy/signal/signaltools.py\", line 204, in fftconvolve\n    _check_valid_mode_shapes(s1, s2)\n  File \"/usr/lib/python2.7/dist-packages/scipy/signal/signaltools.py\", line 64, in _check_valid_mode_shapes\n    \"in1 should have at least as many items as in2 in \"\nValueError: in1 should have at least as many items as in2 in every dimension for 'valid' mode.\n\n----------------------------------------------------------------------\n```\n\n", "before_files": [{"content": "import numpy as np\nfrom scipy.signal import fftconvolve\n\ndef bkfilter(X, low=6, high=32, K=12):\n    \"\"\"\n    Baxter-King bandpass filter\n\n    Parameters\n    ----------\n    X : array-like\n        A 1 or 2d ndarray. If 2d, variables are assumed to be in columns.\n    low : float\n        Minimum period for oscillations, ie., Baxter and King suggest that\n        the Burns-Mitchell U.S. business cycle has 6 for quarterly data and\n        1.5 for annual data.\n    high : float\n        Maximum period for oscillations BK suggest that the U.S.\n        business cycle has 32 for quarterly data and 8 for annual data.\n    K : int\n        Lead-lag length of the filter. Baxter and King propose a truncation\n        length of 12 for quarterly data and 3 for annual data.\n\n    Returns\n    -------\n    Y : array\n        Cyclical component of X\n\n    References\n    ---------- ::\n    Baxter, M. and R. G. King. \"Measuring Business Cycles: Approximate\n        Band-Pass Filters for Economic Time Series.\" *Review of Economics and\n        Statistics*, 1999, 81(4), 575-593.\n\n    Notes\n    -----\n    Returns a centered weighted moving average of the original series. Where\n    the weights a[j] are computed ::\n\n      a[j] = b[j] + theta, for j = 0, +/-1, +/-2, ... +/- K\n      b[0] = (omega_2 - omega_1)/pi\n      b[j] = 1/(pi*j)(sin(omega_2*j)-sin(omega_1*j), for j = +/-1, +/-2,...\n\n    and theta is a normalizing constant ::\n\n      theta = -sum(b)/(2K+1)\n\n    Examples\n    --------\n    >>> import statsmodels.api as sm\n    >>> dta = sm.datasets.macrodata.load()\n    >>> X = dta.data['realinv']\n    >>> Y = sm.tsa.filters.bkfilter(X, 6, 24, 12)\n    \"\"\"\n#TODO: change the docstring to ..math::?\n#TODO: allow windowing functions to correct for Gibb's Phenomenon?\n# adjust bweights (symmetrically) by below before demeaning\n# Lancosz Sigma Factors np.sinc(2*j/(2.*K+1))\n    if low < 2:\n        raise ValueError(\"low cannot be less than 2\")\n    X = np.asarray(X)\n    omega_1 = 2.*np.pi/high # convert from freq. to periodicity\n    omega_2 = 2.*np.pi/low\n    bweights = np.zeros(2*K+1)\n    bweights[K] = (omega_2 - omega_1)/np.pi # weight at zero freq.\n    j = np.arange(1,int(K)+1)\n    weights = 1/(np.pi*j)*(np.sin(omega_2*j)-np.sin(omega_1*j))\n    bweights[K+j] = weights # j is an idx\n    bweights[:K] = weights[::-1] # make symmetric weights\n    bweights -= bweights.mean() # make sure weights sum to zero\n    if X.ndim == 2:\n        bweights = bweights[:,None]\n    return fftconvolve(bweights, X, mode='valid') # get a centered moving avg/\n                                                  # convolution\n", "path": "statsmodels/tsa/filters/bk_filter.py"}]}