prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  "Koch Fractal" example is missing an import [develop branch]
  The "Koch Fractal" example is missing the import for the `reduce()` function.
  
  ```
  Traceback (most recent call last):
    File "C:\Anaconda3\lib\site-packages\pyqtgraph\examples\fractal.py", line 106, in <module>
      update()
    File "C:\Anaconda3\lib\site-packages\pyqtgraph\examples\fractal.py", line 86, in update
      mats = reduce(matmul, mats)
  NameError: name 'reduce' is not defined
  ```
  
  Adding `from functools import reduce` fixes it.
  
  </issue>
  <code>
  [start of examples/fractal.py]
  1 # -*- coding: utf-8 -*-
  2 """
  3 Displays an interactive Koch fractal
  4 """
  5 import initExample ## Add path to library (just for examples; you do not need this)
  6 
  7 import pyqtgraph as pg
  8 from pyqtgraph.Qt import QtCore, QtGui
  9 import numpy as np
  10 
  11 app = QtGui.QApplication([])
  12 
  13 # Set up UI widgets
  14 win = pg.QtGui.QWidget()
  15 win.setWindowTitle('pyqtgraph example: fractal demo')
  16 layout = pg.QtGui.QGridLayout()
  17 win.setLayout(layout)
  18 layout.setContentsMargins(0, 0, 0, 0)
  19 depthLabel = pg.QtGui.QLabel('fractal depth:')
  20 layout.addWidget(depthLabel, 0, 0)
  21 depthSpin = pg.SpinBox(value=5, step=1, bounds=[1, 10], delay=0, int=True)
  22 depthSpin.resize(100, 20)
  23 layout.addWidget(depthSpin, 0, 1)
  24 w = pg.GraphicsLayoutWidget()
  25 layout.addWidget(w, 1, 0, 1, 2)
  26 win.show()
  27 
  28 # Set up graphics
  29 v = w.addViewBox()
  30 v.setAspectLocked()
  31 baseLine = pg.PolyLineROI([[0, 0], [1, 0], [1.5, 1], [2, 0], [3, 0]], pen=(0, 255, 0, 100), movable=False)
  32 v.addItem(baseLine)
  33 fc = pg.PlotCurveItem(pen=(255, 255, 255, 200), antialias=True)
  34 v.addItem(fc)
  35 v.autoRange()
  36 
  37 
  38 transformMap = [0, 0, None]
  39 
  40 
  41 def update():
  42     # recalculate and redraw the fractal curve
  43     
  44     depth = depthSpin.value()
  45     pts = baseLine.getState()['points']
  46     nbseg = len(pts) - 1
  47     nseg = nbseg**depth
  48     
  49     # Get a transformation matrix for each base segment
  50     trs = []
  51     v1 = pts[-1] - pts[0]
  52     l1 = v1.length()
  53     for i in range(len(pts)-1):
  54         p1 = pts[i]
  55         p2 = pts[i+1]
  56         v2 = p2 - p1
  57         t = p1 - pts[0]
  58         r = v2.angle(v1)
  59         s = v2.length() / l1
  60         trs.append(pg.SRTTransform({'pos': t, 'scale': (s, s), 'angle': r}))
  61 
  62     basePts = [np.array(list(pt) + [1]) for pt in baseLine.getState()['points']]
  63     baseMats = np.dstack([tr.matrix().T for tr in trs]).transpose(2, 0, 1)
  64 
  65     # Generate an array of matrices to transform base points
  66     global transformMap
  67     if transformMap[:2] != [depth, nbseg]:
  68         # we can cache the transform index to save a little time..
  69         nseg = nbseg**depth
  70         matInds = np.empty((depth, nseg), dtype=int)
  71         for i in range(depth):
  72             matInds[i] = np.tile(np.repeat(np.arange(nbseg), nbseg**(depth-1-i)), nbseg**i)
  73         transformMap = [depth, nbseg, matInds]
  74         
  75     # Each column in matInds contains the indices referring to the base transform
  76     # matrices that must be multiplied together to generate the final transform
  77     # for each segment of the fractal 
  78     matInds = transformMap[2]
  79     
  80     # Collect all matrices needed for generating fractal curve
  81     mats = baseMats[matInds]
  82     
  83     # Magic-multiply stacks of matrices together
  84     def matmul(a, b):
  85         return np.sum(np.transpose(a,(0,2,1))[..., None] * b[..., None, :], axis=-3)
  86     mats = reduce(matmul, mats)
  87     
  88     # Transform base points through matrix array
  89     pts = np.empty((nseg * nbseg + 1, 2))
  90     for l in range(len(trs)):
  91         bp = basePts[l]
  92         pts[l:-1:len(trs)] = np.dot(mats, bp)[:, :2]
  93     
  94     # Finish the curve with the last base point
  95     pts[-1] = basePts[-1][:2]
  96 
  97     # update fractal curve with new points
  98     fc.setData(pts[:,0], pts[:,1])
  99 
  100 
  101 # Update the fractal whenever the base shape or depth has changed
  102 baseLine.sigRegionChanged.connect(update)
  103 depthSpin.valueChanged.connect(update)
  104 
  105 # Initialize
  106 update()
  107 
  108 
  109 ## Start Qt event loop unless running in interactive mode or using pyside.
  110 if __name__ == '__main__':
  111     import sys
  112     if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
  113         QtGui.QApplication.instance().exec_()
  114 
  115 
  116 
  117 
  118 
  119 
  120 
  121 
  122
  [end of examples/fractal.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/examples/fractal.py b/examples/fractal.py
  --- a/examples/fractal.py
  +++ b/examples/fractal.py
  @@ -4,6 +4,7 @@
   """
   import initExample ## Add path to library (just for examples; you do not need this)
   
  +from functools import reduce
   import pyqtgraph as pg
   from pyqtgraph.Qt import QtCore, QtGui
   import numpy as np
  @@ -111,12 +112,4 @@
       import sys
       if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
           QtGui.QApplication.instance().exec_()
  -
  -
  -
  -
  -
  -
  -
  -
       
  \ No newline at end of file
  
verification_info: {"golden_diff": "diff --git a/examples/fractal.py b/examples/fractal.py\n--- a/examples/fractal.py\n+++ b/examples/fractal.py\n@@ -4,6 +4,7 @@\n \"\"\"\n import initExample ## Add path to library (just for examples; you do not need this)\n \n+from functools import reduce\n import pyqtgraph as pg\n from pyqtgraph.Qt import QtCore, QtGui\n import numpy as np\n@@ -111,12 +112,4 @@\n     import sys\n     if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):\n         QtGui.QApplication.instance().exec_()\n-\n-\n-\n-\n-\n-\n-\n-\n     \n\\ No newline at end of file\n", "issue": "\"Koch Fractal\" example is missing an import [develop branch]\nThe \"Koch Fractal\" example is missing the import for the `reduce()` function.\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"C:\\Anaconda3\\lib\\site-packages\\pyqtgraph\\examples\\fractal.py\", line 106, in <module>\r\n    update()\r\n  File \"C:\\Anaconda3\\lib\\site-packages\\pyqtgraph\\examples\\fractal.py\", line 86, in update\r\n    mats = reduce(matmul, mats)\r\nNameError: name 'reduce' is not defined\r\n```\r\n\r\nAdding `from functools import reduce` fixes it.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"\nDisplays an interactive Koch fractal\n\"\"\"\nimport initExample ## Add path to library (just for examples; you do not need this)\n\nimport pyqtgraph as pg\nfrom pyqtgraph.Qt import QtCore, QtGui\nimport numpy as np\n\napp = QtGui.QApplication([])\n\n# Set up UI widgets\nwin = pg.QtGui.QWidget()\nwin.setWindowTitle('pyqtgraph example: fractal demo')\nlayout = pg.QtGui.QGridLayout()\nwin.setLayout(layout)\nlayout.setContentsMargins(0, 0, 0, 0)\ndepthLabel = pg.QtGui.QLabel('fractal depth:')\nlayout.addWidget(depthLabel, 0, 0)\ndepthSpin = pg.SpinBox(value=5, step=1, bounds=[1, 10], delay=0, int=True)\ndepthSpin.resize(100, 20)\nlayout.addWidget(depthSpin, 0, 1)\nw = pg.GraphicsLayoutWidget()\nlayout.addWidget(w, 1, 0, 1, 2)\nwin.show()\n\n# Set up graphics\nv = w.addViewBox()\nv.setAspectLocked()\nbaseLine = pg.PolyLineROI([[0, 0], [1, 0], [1.5, 1], [2, 0], [3, 0]], pen=(0, 255, 0, 100), movable=False)\nv.addItem(baseLine)\nfc = pg.PlotCurveItem(pen=(255, 255, 255, 200), antialias=True)\nv.addItem(fc)\nv.autoRange()\n\n\ntransformMap = [0, 0, None]\n\n\ndef update():\n    # recalculate and redraw the fractal curve\n    \n    depth = depthSpin.value()\n    pts = baseLine.getState()['points']\n    nbseg = len(pts) - 1\n    nseg = nbseg**depth\n    \n    # Get a transformation matrix for each base segment\n    trs = []\n    v1 = pts[-1] - pts[0]\n    l1 = v1.length()\n    for i in range(len(pts)-1):\n        p1 = pts[i]\n        p2 = pts[i+1]\n        v2 = p2 - p1\n        t = p1 - pts[0]\n        r = v2.angle(v1)\n        s = v2.length() / l1\n        trs.append(pg.SRTTransform({'pos': t, 'scale': (s, s), 'angle': r}))\n\n    basePts = [np.array(list(pt) + [1]) for pt in baseLine.getState()['points']]\n    baseMats = np.dstack([tr.matrix().T for tr in trs]).transpose(2, 0, 1)\n\n    # Generate an array of matrices to transform base points\n    global transformMap\n    if transformMap[:2] != [depth, nbseg]:\n        # we can cache the transform index to save a little time..\n        nseg = nbseg**depth\n        matInds = np.empty((depth, nseg), dtype=int)\n        for i in range(depth):\n            matInds[i] = np.tile(np.repeat(np.arange(nbseg), nbseg**(depth-1-i)), nbseg**i)\n        transformMap = [depth, nbseg, matInds]\n        \n    # Each column in matInds contains the indices referring to the base transform\n    # matrices that must be multiplied together to generate the final transform\n    # for each segment of the fractal \n    matInds = transformMap[2]\n    \n    # Collect all matrices needed for generating fractal curve\n    mats = baseMats[matInds]\n    \n    # Magic-multiply stacks of matrices together\n    def matmul(a, b):\n        return np.sum(np.transpose(a,(0,2,1))[..., None] * b[..., None, :], axis=-3)\n    mats = reduce(matmul, mats)\n    \n    # Transform base points through matrix array\n    pts = np.empty((nseg * nbseg + 1, 2))\n    for l in range(len(trs)):\n        bp = basePts[l]\n        pts[l:-1:len(trs)] = np.dot(mats, bp)[:, :2]\n    \n    # Finish the curve with the last base point\n    pts[-1] = basePts[-1][:2]\n\n    # update fractal curve with new points\n    fc.setData(pts[:,0], pts[:,1])\n\n\n# Update the fractal whenever the base shape or depth has changed\nbaseLine.sigRegionChanged.connect(update)\ndepthSpin.valueChanged.connect(update)\n\n# Initialize\nupdate()\n\n\n## Start Qt event loop unless running in interactive mode or using pyside.\nif __name__ == '__main__':\n    import sys\n    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):\n        QtGui.QApplication.instance().exec_()\n\n\n\n\n\n\n\n\n    ", "path": "examples/fractal.py"}]}