prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  examples/total.py won't run in Python3
  The line `total /= 3` should read instead, `total = total / 3`.
  
  
  </issue>
  <code>
  [start of examples/sieve.py]
  1 #!/usr/bin/env python
  2 #
  3 # sieve: demonstrate sieving and polygonizing of raster features.
  4 
  5 import subprocess
  6 
  7 import numpy as np
  8 import rasterio
  9 from rasterio.features import sieve, shapes
  10 
  11 
  12 # Register GDAL and OGR drivers.
  13 with rasterio.Env():
  14 
  15     # Read a raster to be sieved.
  16     with rasterio.open('tests/data/shade.tif') as src:
  17         shade = src.read(1)
  18 
  19     # Print the number of shapes in the source raster.
  20     print("Slope shapes: %d" % len(list(shapes(shade))))
  21 
  22     # Sieve out features 13 pixels or smaller.
  23     sieved = sieve(shade, 13, out=np.zeros(src.shape, src.dtypes[0]))
  24 
  25     # Print the number of shapes in the sieved raster.
  26     print("Sieved (13) shapes: %d" % len(list(shapes(sieved))))
  27 
  28     # Write out the sieved raster.
  29     kwargs = src.meta
  30     kwargs['transform'] = kwargs.pop('affine')
  31     with rasterio.open('example-sieved.tif', 'w', **kwargs) as dst:
  32         dst.write(sieved, indexes=1)
  33 
  34 # Dump out gdalinfo's report card and open (or "eog") the TIFF.
  35 print(subprocess.check_output(
  36     ['gdalinfo', '-stats', 'example-sieved.tif']))
  37 subprocess.call(['open', 'example-sieved.tif'])
  38
  [end of examples/sieve.py]
  [start of examples/total.py]
  1 import numpy as np
  2 import rasterio
  3 import subprocess
  4 
  5 with rasterio.Env(CPL_DEBUG=True):
  6 
  7     # Read raster bands directly to Numpy arrays.
  8     with rasterio.open('tests/data/RGB.byte.tif') as src:
  9         r, g, b = src.read()
  10 
  11     # Combine arrays using the 'iadd' ufunc. Expecting that the sum will
  12     # exceed the 8-bit integer range, initialize it as 16-bit. Adding other
  13     # arrays to it in-place converts those arrays up and preserves the type
  14     # of the total array.
  15     total = np.zeros(r.shape, dtype=rasterio.uint16)
  16     for band in (r, g, b):
  17         total += band
  18     total /= 3
  19 
  20     # Write the product as a raster band to a new 8-bit file. For keyword
  21     # arguments, we start with the meta attributes of the source file, but
  22     # then change the band count to 1, set the dtype to uint8, and specify
  23     # LZW compression.
  24     kwargs = src.meta
  25     kwargs.update(
  26         dtype=rasterio.uint8,
  27         count=1,
  28         compress='lzw')
  29 
  30     with rasterio.open('example-total.tif', 'w', **kwargs) as dst:
  31         dst.write(total.astype(rasterio.uint8), indexes=1)
  32 
  33 # Dump out gdalinfo's report card and open the image.
  34 info = subprocess.check_output(
  35     ['gdalinfo', '-stats', 'example-total.tif'])
  36 print(info)
  37 subprocess.call(['open', 'example-total.tif'])
  38
  [end of examples/total.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/sieve.py b/examples/sieve.py
  --- a/examples/sieve.py
  +++ b/examples/sieve.py
  @@ -27,7 +27,7 @@
   
       # Write out the sieved raster.
       kwargs = src.meta
  -    kwargs['transform'] = kwargs.pop('affine')
  +    kwargs['transform'] = rasterio.transform.guard_transform(kwargs['transform'])
       with rasterio.open('example-sieved.tif', 'w', **kwargs) as dst:
           dst.write(sieved, indexes=1)
   
  diff --git a/examples/total.py b/examples/total.py
  --- a/examples/total.py
  +++ b/examples/total.py
  @@ -1,3 +1,4 @@
  +from __future__ import division
   import numpy as np
   import rasterio
   import subprocess
  @@ -15,7 +16,7 @@
       total = np.zeros(r.shape, dtype=rasterio.uint16)
       for band in (r, g, b):
           total += band
  -    total /= 3
  +    total = total // 3
   
       # Write the product as a raster band to a new 8-bit file. For keyword
       # arguments, we start with the meta attributes of the source file, but
  
verification_info: {"golden_diff": "diff --git a/examples/sieve.py b/examples/sieve.py\n--- a/examples/sieve.py\n+++ b/examples/sieve.py\n@@ -27,7 +27,7 @@\n \n     # Write out the sieved raster.\n     kwargs = src.meta\n-    kwargs['transform'] = kwargs.pop('affine')\n+    kwargs['transform'] = rasterio.transform.guard_transform(kwargs['transform'])\n     with rasterio.open('example-sieved.tif', 'w', **kwargs) as dst:\n         dst.write(sieved, indexes=1)\n \ndiff --git a/examples/total.py b/examples/total.py\n--- a/examples/total.py\n+++ b/examples/total.py\n@@ -1,3 +1,4 @@\n+from __future__ import division\n import numpy as np\n import rasterio\n import subprocess\n@@ -15,7 +16,7 @@\n     total = np.zeros(r.shape, dtype=rasterio.uint16)\n     for band in (r, g, b):\n         total += band\n-    total /= 3\n+    total = total // 3\n \n     # Write the product as a raster band to a new 8-bit file. For keyword\n     # arguments, we start with the meta attributes of the source file, but\n", "issue": "examples/total.py won't run in Python3\nThe line `total /= 3` should read instead, `total = total / 3`.\r\n\n", "before_files": [{"content": "#!/usr/bin/env python\n#\n# sieve: demonstrate sieving and polygonizing of raster features.\n\nimport subprocess\n\nimport numpy as np\nimport rasterio\nfrom rasterio.features import sieve, shapes\n\n\n# Register GDAL and OGR drivers.\nwith rasterio.Env():\n\n    # Read a raster to be sieved.\n    with rasterio.open('tests/data/shade.tif') as src:\n        shade = src.read(1)\n\n    # Print the number of shapes in the source raster.\n    print(\"Slope shapes: %d\" % len(list(shapes(shade))))\n\n    # Sieve out features 13 pixels or smaller.\n    sieved = sieve(shade, 13, out=np.zeros(src.shape, src.dtypes[0]))\n\n    # Print the number of shapes in the sieved raster.\n    print(\"Sieved (13) shapes: %d\" % len(list(shapes(sieved))))\n\n    # Write out the sieved raster.\n    kwargs = src.meta\n    kwargs['transform'] = kwargs.pop('affine')\n    with rasterio.open('example-sieved.tif', 'w', **kwargs) as dst:\n        dst.write(sieved, indexes=1)\n\n# Dump out gdalinfo's report card and open (or \"eog\") the TIFF.\nprint(subprocess.check_output(\n    ['gdalinfo', '-stats', 'example-sieved.tif']))\nsubprocess.call(['open', 'example-sieved.tif'])\n", "path": "examples/sieve.py"}, {"content": "import numpy as np\nimport rasterio\nimport subprocess\n\nwith rasterio.Env(CPL_DEBUG=True):\n\n    # Read raster bands directly to Numpy arrays.\n    with rasterio.open('tests/data/RGB.byte.tif') as src:\n        r, g, b = src.read()\n\n    # Combine arrays using the 'iadd' ufunc. Expecting that the sum will\n    # exceed the 8-bit integer range, initialize it as 16-bit. Adding other\n    # arrays to it in-place converts those arrays up and preserves the type\n    # of the total array.\n    total = np.zeros(r.shape, dtype=rasterio.uint16)\n    for band in (r, g, b):\n        total += band\n    total /= 3\n\n    # Write the product as a raster band to a new 8-bit file. For keyword\n    # arguments, we start with the meta attributes of the source file, but\n    # then change the band count to 1, set the dtype to uint8, and specify\n    # LZW compression.\n    kwargs = src.meta\n    kwargs.update(\n        dtype=rasterio.uint8,\n        count=1,\n        compress='lzw')\n\n    with rasterio.open('example-total.tif', 'w', **kwargs) as dst:\n        dst.write(total.astype(rasterio.uint8), indexes=1)\n\n# Dump out gdalinfo's report card and open the image.\ninfo = subprocess.check_output(\n    ['gdalinfo', '-stats', 'example-total.tif'])\nprint(info)\nsubprocess.call(['open', 'example-total.tif'])\n", "path": "examples/total.py"}]}