prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  pcov TypeError in kit._leastsq
  In kit._leastsq, if the line 62 if statement is not passed, the consequent else statement makes pcov data type float, triggering"TypeError: 'int' object is not subscriptable" in line 72-73:
  
  72:      try:
  73:                error.append(np.absolute(pcov[i][i]) ** 0.5)
  
  Line 74 picks up index out of bound errors, not sure if it was meant to catch the type error.
  
  74:      except IndexError:
  75:                 error.append(0.00)
  
  Error is bypassed if I put a 2D array into line 68, but have not spent the time considering what this array should look like.
  
  </issue>
  <code>
  [start of WrightTools/kit/_leastsq.py]
  1 """Least-square fitting tools."""
  2 
  3 
  4 # --- import --------------------------------------------------------------------------------------
  5 
  6 
  7 from ._utilities import Timer
  8 
  9 import numpy as np
  10 
  11 from scipy import optimize as scipy_optimize
  12 
  13 
  14 # --- define --------------------------------------------------------------------------------------
  15 
  16 
  17 __all__ = ["leastsqfitter"]
  18 
  19 
  20 # --- functions -----------------------------------------------------------------------------------
  21 
  22 
  23 def leastsqfitter(p0, datax, datay, function, verbose=False, cov_verbose=False):
  24     """Conveniently call scipy.optmize.leastsq().
  25 
  26     Returns fit parameters and their errors.
  27 
  28     Parameters
  29     ----------
  30     p0 : list
  31         list of guess parameters to pass to function
  32     datax : array
  33         array of independent values
  34     datay : array
  35         array of dependent values
  36     function : function
  37         function object to fit data to. Must be of the callable form function(p, x)
  38     verbose : bool
  39         toggles printing of fit time, fit params, and fit param errors
  40     cov_verbose : bool
  41         toggles printing of covarience matrix
  42 
  43     Returns
  44     -------
  45     pfit_leastsq : list
  46         list of fit parameters. s.t. the error between datay and function(p, datax) is minimized
  47     perr_leastsq : list
  48         list of fit parameter errors (1 std)
  49     """
  50     timer = Timer(verbose=False)
  51     with timer:
  52         # define error function
  53         def errfunc(p, x, y):
  54             return y - function(p, x)
  55 
  56         # run optimization
  57         pfit_leastsq, pcov, infodict, errmsg, success = scipy_optimize.leastsq(
  58             errfunc, p0, args=(datax, datay), full_output=1, epsfcn=0.0001
  59         )
  60         # calculate covarience matrix
  61         # original idea https://stackoverflow.com/a/21844726
  62         if (len(datay) > len(p0)) and pcov is not None:
  63             s_sq = (errfunc(pfit_leastsq, datax, datay) ** 2).sum() / (len(datay) - len(p0))
  64             pcov = pcov * s_sq
  65             if cov_verbose:
  66                 print(pcov)
  67         else:
  68             pcov = np.inf
  69         # calculate and write errors
  70         error = []
  71         for i in range(len(pfit_leastsq)):
  72             try:
  73                 error.append(np.absolute(pcov[i][i]) ** 0.5)
  74             except IndexError:
  75                 error.append(0.00)
  76         perr_leastsq = np.array(error)
  77     # exit
  78     if verbose:
  79         print("fit params:       ", pfit_leastsq)
  80         print("fit params error: ", perr_leastsq)
  81         print("fitting done in %f seconds" % timer.interval)
  82     return pfit_leastsq, perr_leastsq
  83
  [end of WrightTools/kit/_leastsq.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/WrightTools/kit/_leastsq.py b/WrightTools/kit/_leastsq.py
  --- a/WrightTools/kit/_leastsq.py
  +++ b/WrightTools/kit/_leastsq.py
  @@ -65,7 +65,7 @@
               if cov_verbose:
                   print(pcov)
           else:
  -            pcov = np.inf
  +            pcov = np.array(np.inf)
           # calculate and write errors
           error = []
           for i in range(len(pfit_leastsq)):
  
verification_info: {"golden_diff": "diff --git a/WrightTools/kit/_leastsq.py b/WrightTools/kit/_leastsq.py\n--- a/WrightTools/kit/_leastsq.py\n+++ b/WrightTools/kit/_leastsq.py\n@@ -65,7 +65,7 @@\n             if cov_verbose:\n                 print(pcov)\n         else:\n-            pcov = np.inf\n+            pcov = np.array(np.inf)\n         # calculate and write errors\n         error = []\n         for i in range(len(pfit_leastsq)):\n", "issue": "pcov TypeError in kit._leastsq\nIn kit._leastsq, if the line 62 if statement is not passed, the consequent else statement makes pcov data type float, triggering\"TypeError: 'int' object is not subscriptable\" in line 72-73:\r\n\r\n72:      try:\r\n73:                error.append(np.absolute(pcov[i][i]) ** 0.5)\r\n\r\nLine 74 picks up index out of bound errors, not sure if it was meant to catch the type error.\r\n\r\n74:      except IndexError:\r\n75:                 error.append(0.00)\r\n\r\nError is bypassed if I put a 2D array into line 68, but have not spent the time considering what this array should look like.\n", "before_files": [{"content": "\"\"\"Least-square fitting tools.\"\"\"\n\n\n# --- import --------------------------------------------------------------------------------------\n\n\nfrom ._utilities import Timer\n\nimport numpy as np\n\nfrom scipy import optimize as scipy_optimize\n\n\n# --- define --------------------------------------------------------------------------------------\n\n\n__all__ = [\"leastsqfitter\"]\n\n\n# --- functions -----------------------------------------------------------------------------------\n\n\ndef leastsqfitter(p0, datax, datay, function, verbose=False, cov_verbose=False):\n    \"\"\"Conveniently call scipy.optmize.leastsq().\n\n    Returns fit parameters and their errors.\n\n    Parameters\n    ----------\n    p0 : list\n        list of guess parameters to pass to function\n    datax : array\n        array of independent values\n    datay : array\n        array of dependent values\n    function : function\n        function object to fit data to. Must be of the callable form function(p, x)\n    verbose : bool\n        toggles printing of fit time, fit params, and fit param errors\n    cov_verbose : bool\n        toggles printing of covarience matrix\n\n    Returns\n    -------\n    pfit_leastsq : list\n        list of fit parameters. s.t. the error between datay and function(p, datax) is minimized\n    perr_leastsq : list\n        list of fit parameter errors (1 std)\n    \"\"\"\n    timer = Timer(verbose=False)\n    with timer:\n        # define error function\n        def errfunc(p, x, y):\n            return y - function(p, x)\n\n        # run optimization\n        pfit_leastsq, pcov, infodict, errmsg, success = scipy_optimize.leastsq(\n            errfunc, p0, args=(datax, datay), full_output=1, epsfcn=0.0001\n        )\n        # calculate covarience matrix\n        # original idea https://stackoverflow.com/a/21844726\n        if (len(datay) > len(p0)) and pcov is not None:\n            s_sq = (errfunc(pfit_leastsq, datax, datay) ** 2).sum() / (len(datay) - len(p0))\n            pcov = pcov * s_sq\n            if cov_verbose:\n                print(pcov)\n        else:\n            pcov = np.inf\n        # calculate and write errors\n        error = []\n        for i in range(len(pfit_leastsq)):\n            try:\n                error.append(np.absolute(pcov[i][i]) ** 0.5)\n            except IndexError:\n                error.append(0.00)\n        perr_leastsq = np.array(error)\n    # exit\n    if verbose:\n        print(\"fit params:       \", pfit_leastsq)\n        print(\"fit params error: \", perr_leastsq)\n        print(\"fitting done in %f seconds\" % timer.interval)\n    return pfit_leastsq, perr_leastsq\n", "path": "WrightTools/kit/_leastsq.py"}]}