prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  numdifftools dependency
  Original Launchpad bug 653902: https://bugs.launchpad.net/statsmodels/+bug/653902
  Reported by: vincent-vincentdavis (Vincent Davis).
  
  statsmodels/_init_.py imports tsa
  Which then returns an exception from statsmodels/tsa/var.py "raise Warning("You need to install numdifftools to try out the AR model")"
  Should numdifftools be a dependency for all of statsmodels ?
  
  
  </issue>
  <code>
  [start of statsmodels/tsa/mlemodel.py]
  1 """Base Classes for Likelihood Models in time series analysis
  2 
  3 Warning: imports numdifftools
  4 
  5 
  6 
  7 Created on Sun Oct 10 15:00:47 2010
  8 
  9 Author: josef-pktd
  10 License: BSD
  11 
  12 """
  13 
  14 import numpy as np
  15 
  16 import numdifftools as ndt
  17 
  18 from statsmodels.base.model import LikelihoodModel
  19 
  20 #copied from sandbox/regression/mle.py
  21 #TODO: I take it this is only a stub and should be included in another
  22 # model class?
  23 class TSMLEModel(LikelihoodModel):
  24     """
  25     univariate time series model for estimation with maximum likelihood
  26 
  27     Note: This is not working yet
  28     """
  29 
  30     def __init__(self, endog, exog=None):
  31         #need to override p,q (nar,nma) correctly
  32         super(TSMLEModel, self).__init__(endog, exog)
  33         #set default arma(1,1)
  34         self.nar = 1
  35         self.nma = 1
  36         #self.initialize()
  37 
  38     def geterrors(self, params):
  39         raise NotImplementedError
  40 
  41     def loglike(self, params):
  42         """
  43         Loglikelihood for timeseries model
  44 
  45         Notes
  46         -----
  47         needs to be overwritten by subclass
  48         """
  49         raise NotImplementedError
  50 
  51 
  52     def score(self, params):
  53         """
  54         Score vector for Arma model
  55         """
  56         #return None
  57         #print params
  58         jac = ndt.Jacobian(self.loglike, stepMax=1e-4)
  59         return jac(params)[-1]
  60 
  61     def hessian(self, params):
  62         """
  63         Hessian of arma model.  Currently uses numdifftools
  64         """
  65         #return None
  66         Hfun = ndt.Jacobian(self.score, stepMax=1e-4)
  67         return Hfun(params)[-1]
  68 
  69 
  70     def fit(self, start_params=None, maxiter=5000, method='fmin', tol=1e-08):
  71         '''estimate model by minimizing negative loglikelihood
  72 
  73         does this need to be overwritten ?
  74         '''
  75         if start_params is None and hasattr(self, '_start_params'):
  76             start_params = self._start_params
  77         #start_params = np.concatenate((0.05*np.ones(self.nar + self.nma), [1]))
  78         mlefit = super(TSMLEModel, self).fit(start_params=start_params,
  79                 maxiter=maxiter, method=method, tol=tol)
  80         return mlefit
  81
  [end of statsmodels/tsa/mlemodel.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/mlemodel.py b/statsmodels/tsa/mlemodel.py
  --- a/statsmodels/tsa/mlemodel.py
  +++ b/statsmodels/tsa/mlemodel.py
  @@ -13,7 +13,10 @@
   
   import numpy as np
   
  -import numdifftools as ndt
  +try:
  +    import numdifftools as ndt
  +except:
  +    pass
   
   from statsmodels.base.model import LikelihoodModel
  
verification_info: {"golden_diff": "diff --git a/statsmodels/tsa/mlemodel.py b/statsmodels/tsa/mlemodel.py\n--- a/statsmodels/tsa/mlemodel.py\n+++ b/statsmodels/tsa/mlemodel.py\n@@ -13,7 +13,10 @@\n \n import numpy as np\n \n-import numdifftools as ndt\n+try:\n+    import numdifftools as ndt\n+except:\n+    pass\n \n from statsmodels.base.model import LikelihoodModel\n", "issue": "numdifftools dependency\nOriginal Launchpad bug 653902: https://bugs.launchpad.net/statsmodels/+bug/653902\nReported by: vincent-vincentdavis (Vincent Davis).\n\nstatsmodels/_init_.py imports tsa\nWhich then returns an exception from statsmodels/tsa/var.py \"raise Warning(\"You need to install numdifftools to try out the AR model\")\"\nShould numdifftools be a dependency for all of statsmodels ?\n\n", "before_files": [{"content": "\"\"\"Base Classes for Likelihood Models in time series analysis\n\nWarning: imports numdifftools\n\n\n\nCreated on Sun Oct 10 15:00:47 2010\n\nAuthor: josef-pktd\nLicense: BSD\n\n\"\"\"\n\nimport numpy as np\n\nimport numdifftools as ndt\n\nfrom statsmodels.base.model import LikelihoodModel\n\n#copied from sandbox/regression/mle.py\n#TODO: I take it this is only a stub and should be included in another\n# model class?\nclass TSMLEModel(LikelihoodModel):\n    \"\"\"\n    univariate time series model for estimation with maximum likelihood\n\n    Note: This is not working yet\n    \"\"\"\n\n    def __init__(self, endog, exog=None):\n        #need to override p,q (nar,nma) correctly\n        super(TSMLEModel, self).__init__(endog, exog)\n        #set default arma(1,1)\n        self.nar = 1\n        self.nma = 1\n        #self.initialize()\n\n    def geterrors(self, params):\n        raise NotImplementedError\n\n    def loglike(self, params):\n        \"\"\"\n        Loglikelihood for timeseries model\n\n        Notes\n        -----\n        needs to be overwritten by subclass\n        \"\"\"\n        raise NotImplementedError\n\n\n    def score(self, params):\n        \"\"\"\n        Score vector for Arma model\n        \"\"\"\n        #return None\n        #print params\n        jac = ndt.Jacobian(self.loglike, stepMax=1e-4)\n        return jac(params)[-1]\n\n    def hessian(self, params):\n        \"\"\"\n        Hessian of arma model.  Currently uses numdifftools\n        \"\"\"\n        #return None\n        Hfun = ndt.Jacobian(self.score, stepMax=1e-4)\n        return Hfun(params)[-1]\n\n\n    def fit(self, start_params=None, maxiter=5000, method='fmin', tol=1e-08):\n        '''estimate model by minimizing negative loglikelihood\n\n        does this need to be overwritten ?\n        '''\n        if start_params is None and hasattr(self, '_start_params'):\n            start_params = self._start_params\n        #start_params = np.concatenate((0.05*np.ones(self.nar + self.nma), [1]))\n        mlefit = super(TSMLEModel, self).fit(start_params=start_params,\n                maxiter=maxiter, method=method, tol=tol)\n        return mlefit\n", "path": "statsmodels/tsa/mlemodel.py"}]}