# Buggy code
def geocode(query):
    """
    Geocode a query string to (lat, lon) with the Nominatim geocoder.

    Parameters
    ----------
    query : string
        the query string to geocode

    Returns
    -------
    point : tuple
        the (lat, lon) coordinates returned by the geocoder
    """

    # send the query to the nominatim geocoder and parse the json response
    url_template = "https://nominatim.openstreetmap.org/search?format=json&limit=1&q={}"
    url = url_template.format(query)
    response = requests.get(url, timeout=60)
    results = response.json()

    # if results were returned, parse lat and long out of the result
    if len(results) > 0 and "lat" in results[0] and "lon" in results[0]:
        lat = float(results[0]["lat"])
        lon = float(results[0]["lon"])
        point = (lat, lon)
        log('Geocoded "{}" to {}'.format(query, point))
        return point
    else:
        raise Exception(
            'Nominatim geocoder returned no results for query "{}"'.format(query)
        )


# Traceback (TypeError)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-0d3afc68e96a> in <module>()
----> 1 ox.plot_graph(ox.graph_from_place('Modena, Italy'))

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in graph_from_place(query, network_type, simplify, retain_all, truncate_by_edge, name, which_result, buffer_dist, timeout, memory, max_query_area_size, clean_periphery)
1799     if isinstance(query, str) or isinstance(query, dict):
1800         # if it is a string (place name) or dict (structured place query), then it is a single place
-> 1801         gdf_place = gdf_from_place(query, which_result=which_result, buffer_dist=buffer_dist)
1802         name = query
1803     elif isinstance(query, list):

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in gdf_from_place(query, gdf_name, which_result, buffer_dist)
522
523     # get the data from OSM
--> 524     data = osm_polygon_download(query, limit=which_result)
525     if len(data) >= which_result:
526

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in osm_polygon_download(query, limit, polygon_geojson, pause_duration)
495
496     # request the URL, return the JSON
--> 497     response_json = nominatim_request(params=params, timeout=30)
498     return response_json
499

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in nominatim_request(params, pause_duration, timeout, error_pause_duration)
373         start_time = time.time()
374         log('Requesting {} with timeout={}'.format(prepared_url, timeout))
--> 375         response = requests.get(url, params, timeout=timeout)
376
377         # get the response size and the domain, log result

TypeError: get() takes 1 positional argument but 2 were given

# Fixed code
def geocode(query):
    """
    Geocode a query string to (lat, lon) with the Nominatim geocoder.

    Parameters
    ----------
    query : string
        the query string to geocode

    Returns
    -------
    point : tuple
        the (lat, lon) coordinates returned by the geocoder
    """

    # define the parameters
    params = OrderedDict()
    params["format"] = "json"
    params["limit"] = 1
    params["dedupe"] = (
        0  # prevent OSM from deduping results so we get precisely 'limit' # of results
    )
    params["q"] = query
    response_json = nominatim_request(params=params, timeout=30)

    # if results were returned, parse lat and long out of the result
    if (
        len(response_json) > 0
        and "lat" in response_json[0]
        and "lon" in response_json[0]
    ):
        lat = float(response_json[0]["lat"])
        lon = float(response_json[0]["lon"])
        point = (lat, lon)
        log('Geocoded "{}" to {}'.format(query, point))
        return point
    else:
        raise Exception(
            'Nominatim geocoder returned no results for query "{}"'.format(query)
        )