prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  DOC: update the contextily example in the gallery
  The example about adding a background map to your plot using contextily at https://geopandas.readthedocs.io/en/latest/gallery/plotting_basemap_background.html#sphx-glr-gallery-plotting-basemap-background-py can be updated with the latest contextily (https://github.com/darribas/contextily/releases/tag/v1.0rc2).
  
  For example, the `add_basemap` function is now available in contextily itself.
  
  </issue>
  <code>
  [start of examples/plotting_basemap_background.py]
  1 """
  2 Adding a background map to plots 
  3 --------------------------------
  4 
  5 This example shows how you can add a background basemap to plots created
  6 with the geopandas ``.plot()`` method. This makes use of the
  7 `contextily <https://github.com/darribas/contextily>`__ package to retrieve
  8 web map tiles from several sources (OpenStreetMap, Stamen).
  9 
  10 """
  11 # sphinx_gallery_thumbnail_number = 3
  12 import geopandas
  13 
  14 ###############################################################################
  15 # Let's use the NYC borough boundary data that is available in geopandas
  16 # datasets. Plotting this gives the following result:
  17 
  18 df = geopandas.read_file(geopandas.datasets.get_path('nybb'))
  19 ax = df.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')
  20 
  21 ###############################################################################
  22 # Convert the data to Web Mercator
  23 # ================================
  24 #
  25 # Web map tiles are typically provided in
  26 # `Web Mercator <https://en.wikipedia.org/wiki/Web_Mercator>`__
  27 # (`EPSG 3857 <https://epsg.io/3857>`__), so we need to make sure to convert
  28 # our data first to the same CRS to combine our polygons and background tiles
  29 # in the same map:
  30 
  31 df = df.to_crs(epsg=3857)
  32 
  33 ###############################################################################
  34 # Contextily helper function
  35 # ==========================
  36 #
  37 # We define a small helper function that uses
  38 # `contextily <https://github.com/darribas/contextily>`__ to add a map
  39 # as background to an existing plot: 
  40 
  41 import contextily as ctx
  42 
  43 def add_basemap(ax, zoom, url='http://tile.stamen.com/terrain/tileZ/tileX/tileY.png'):
  44     xmin, xmax, ymin, ymax = ax.axis()
  45     basemap, extent = ctx.bounds2img(xmin, ymin, xmax, ymax, zoom=zoom, url=url)
  46     ax.imshow(basemap, extent=extent, interpolation='bilinear')
  47     # restore original x/y limits
  48     ax.axis((xmin, xmax, ymin, ymax))
  49 
  50 ###############################################################################
  51 # Add background tiles to plot
  52 # ============================
  53 #
  54 # Now we can use the above function to easily add a background map to our
  55 # plot. The `zoom` keyword is required and let's you specify the detail of the
  56 # map tiles (be careful to not specify a too high `zoom` level, as this can
  57 # result in a large download):
  58 
  59 ax = df.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')
  60 add_basemap(ax, zoom=10)
  61 
  62 ###############################################################################
  63 # By default, contextily uses the Stamen Terrain style. We can specify a
  64 # different style using ``ctx.sources``:
  65 
  66 ax = df.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')
  67 add_basemap(ax, zoom=11, url=ctx.sources.ST_TONER_LITE)
  68 ax.set_axis_off()
  69
  [end of examples/plotting_basemap_background.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/plotting_basemap_background.py b/examples/plotting_basemap_background.py
  --- a/examples/plotting_basemap_background.py
  +++ b/examples/plotting_basemap_background.py
  @@ -1,5 +1,5 @@
   """
  -Adding a background map to plots 
  +Adding a background map to plots
   --------------------------------
   
   This example shows how you can add a background basemap to plots created
  @@ -31,38 +31,31 @@
   df = df.to_crs(epsg=3857)
   
   ###############################################################################
  -# Contextily helper function
  -# ==========================
  -#
  -# We define a small helper function that uses
  -# `contextily <https://github.com/darribas/contextily>`__ to add a map
  -# as background to an existing plot: 
   
   import contextily as ctx
   
  -def add_basemap(ax, zoom, url='http://tile.stamen.com/terrain/tileZ/tileX/tileY.png'):
  -    xmin, xmax, ymin, ymax = ax.axis()
  -    basemap, extent = ctx.bounds2img(xmin, ymin, xmax, ymax, zoom=zoom, url=url)
  -    ax.imshow(basemap, extent=extent, interpolation='bilinear')
  -    # restore original x/y limits
  -    ax.axis((xmin, xmax, ymin, ymax))
  -
   ###############################################################################
   # Add background tiles to plot
   # ============================
   #
  -# Now we can use the above function to easily add a background map to our
  -# plot. The `zoom` keyword is required and let's you specify the detail of the
  -# map tiles (be careful to not specify a too high `zoom` level, as this can
  -# result in a large download):
  +# We can use `add_basemap` function of contextily to easily add a background
  +# map to our plot. :
  +
  +ax = df.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')
  +ctx.add_basemap(ax)
  +
  +###############################################################################
  +# We can control the detail of the map tiles using the optional `zoom` keyword
  +# (be careful to not specify a too high `zoom` level,
  +# as this can result in a large download).:
   
   ax = df.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')
  -add_basemap(ax, zoom=10)
  +ctx.add_basemap(ax, zoom=12)
   
   ###############################################################################
   # By default, contextily uses the Stamen Terrain style. We can specify a
  -# different style using ``ctx.sources``:
  +# different style using ``ctx.providers``:
   
   ax = df.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')
  -add_basemap(ax, zoom=11, url=ctx.sources.ST_TONER_LITE)
  +ctx.add_basemap(ax, url=ctx.providers.Stamen.TonerLite)
   ax.set_axis_off()
  
verification_info: {"golden_diff": "diff --git a/examples/plotting_basemap_background.py b/examples/plotting_basemap_background.py\n--- a/examples/plotting_basemap_background.py\n+++ b/examples/plotting_basemap_background.py\n@@ -1,5 +1,5 @@\n \"\"\"\n-Adding a background map to plots \n+Adding a background map to plots\n --------------------------------\n \n This example shows how you can add a background basemap to plots created\n@@ -31,38 +31,31 @@\n df = df.to_crs(epsg=3857)\n \n ###############################################################################\n-# Contextily helper function\n-# ==========================\n-#\n-# We define a small helper function that uses\n-# `contextily <https://github.com/darribas/contextily>`__ to add a map\n-# as background to an existing plot: \n \n import contextily as ctx\n \n-def add_basemap(ax, zoom, url='http://tile.stamen.com/terrain/tileZ/tileX/tileY.png'):\n-    xmin, xmax, ymin, ymax = ax.axis()\n-    basemap, extent = ctx.bounds2img(xmin, ymin, xmax, ymax, zoom=zoom, url=url)\n-    ax.imshow(basemap, extent=extent, interpolation='bilinear')\n-    # restore original x/y limits\n-    ax.axis((xmin, xmax, ymin, ymax))\n-\n ###############################################################################\n # Add background tiles to plot\n # ============================\n #\n-# Now we can use the above function to easily add a background map to our\n-# plot. The `zoom` keyword is required and let's you specify the detail of the\n-# map tiles (be careful to not specify a too high `zoom` level, as this can\n-# result in a large download):\n+# We can use `add_basemap` function of contextily to easily add a background\n+# map to our plot. :\n+\n+ax = df.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')\n+ctx.add_basemap(ax)\n+\n+###############################################################################\n+# We can control the detail of the map tiles using the optional `zoom` keyword\n+# (be careful to not specify a too high `zoom` level,\n+# as this can result in a large download).:\n \n ax = df.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')\n-add_basemap(ax, zoom=10)\n+ctx.add_basemap(ax, zoom=12)\n \n ###############################################################################\n # By default, contextily uses the Stamen Terrain style. We can specify a\n-# different style using ``ctx.sources``:\n+# different style using ``ctx.providers``:\n \n ax = df.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')\n-add_basemap(ax, zoom=11, url=ctx.sources.ST_TONER_LITE)\n+ctx.add_basemap(ax, url=ctx.providers.Stamen.TonerLite)\n ax.set_axis_off()\n", "issue": "DOC: update the contextily example in the gallery\nThe example about adding a background map to your plot using contextily at https://geopandas.readthedocs.io/en/latest/gallery/plotting_basemap_background.html#sphx-glr-gallery-plotting-basemap-background-py can be updated with the latest contextily (https://github.com/darribas/contextily/releases/tag/v1.0rc2).\r\n\r\nFor example, the `add_basemap` function is now available in contextily itself.\n", "before_files": [{"content": "\"\"\"\nAdding a background map to plots \n--------------------------------\n\nThis example shows how you can add a background basemap to plots created\nwith the geopandas ``.plot()`` method. This makes use of the\n`contextily <https://github.com/darribas/contextily>`__ package to retrieve\nweb map tiles from several sources (OpenStreetMap, Stamen).\n\n\"\"\"\n# sphinx_gallery_thumbnail_number = 3\nimport geopandas\n\n###############################################################################\n# Let's use the NYC borough boundary data that is available in geopandas\n# datasets. Plotting this gives the following result:\n\ndf = geopandas.read_file(geopandas.datasets.get_path('nybb'))\nax = df.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')\n\n###############################################################################\n# Convert the data to Web Mercator\n# ================================\n#\n# Web map tiles are typically provided in\n# `Web Mercator <https://en.wikipedia.org/wiki/Web_Mercator>`__\n# (`EPSG 3857 <https://epsg.io/3857>`__), so we need to make sure to convert\n# our data first to the same CRS to combine our polygons and background tiles\n# in the same map:\n\ndf = df.to_crs(epsg=3857)\n\n###############################################################################\n# Contextily helper function\n# ==========================\n#\n# We define a small helper function that uses\n# `contextily <https://github.com/darribas/contextily>`__ to add a map\n# as background to an existing plot: \n\nimport contextily as ctx\n\ndef add_basemap(ax, zoom, url='http://tile.stamen.com/terrain/tileZ/tileX/tileY.png'):\n    xmin, xmax, ymin, ymax = ax.axis()\n    basemap, extent = ctx.bounds2img(xmin, ymin, xmax, ymax, zoom=zoom, url=url)\n    ax.imshow(basemap, extent=extent, interpolation='bilinear')\n    # restore original x/y limits\n    ax.axis((xmin, xmax, ymin, ymax))\n\n###############################################################################\n# Add background tiles to plot\n# ============================\n#\n# Now we can use the above function to easily add a background map to our\n# plot. The `zoom` keyword is required and let's you specify the detail of the\n# map tiles (be careful to not specify a too high `zoom` level, as this can\n# result in a large download):\n\nax = df.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')\nadd_basemap(ax, zoom=10)\n\n###############################################################################\n# By default, contextily uses the Stamen Terrain style. We can specify a\n# different style using ``ctx.sources``:\n\nax = df.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')\nadd_basemap(ax, zoom=11, url=ctx.sources.ST_TONER_LITE)\nax.set_axis_off()\n", "path": "examples/plotting_basemap_background.py"}]}