Skip to content

Commit

Permalink
make deprecation warnings FutureWarnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gboeing committed Feb 1, 2024
1 parent c216106 commit 77dc3b1
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 14 deletions.
2 changes: 2 additions & 0 deletions osmnx/bearing.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def add_edge_bearings(G, precision=None):
else:
warn(
"The `precision` parameter is deprecated and will be removed in the v2.0.0 release.",
FutureWarning,
stacklevel=2,
)

Expand Down Expand Up @@ -300,6 +301,7 @@ def plot_orientation(
warn(
"The `plot_orientation` function moved to the `plot` module. Calling it "
"via the `bearing` module will raise an exception starting with the v2.0.0 release.",
FutureWarning,
stacklevel=2,
)
return plot.plot_orientation(
Expand Down
6 changes: 6 additions & 0 deletions osmnx/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def great_circle_vec(lat1, lng1, lat2, lng2, earth_radius=EARTH_RADIUS_M):
warn(
"The `great_circle_vec` function has been renamed `great_circle`. Calling "
"`great_circle_vec` will raise an error starting in the v2.0.0 release.",
FutureWarning,
stacklevel=2,
)
return great_circle(lat1, lng1, lat2, lng2, earth_radius)
Expand Down Expand Up @@ -162,6 +163,7 @@ def euclidean_dist_vec(y1, x1, y2, x2):
warn(
"The `euclidean_dist_vec` function has been renamed `euclidean`. Calling "
"`euclidean_dist_vec` will raise an error starting in the v2.0.0 release.",
FutureWarning,
stacklevel=2,
)
return euclidean(y1, x1, y2, x2)
Expand Down Expand Up @@ -207,6 +209,7 @@ def add_edge_lengths(G, precision=None, edges=None):
else:
warn(
"The `precision` parameter is deprecated and will be removed in the v2.0.0 release.",
FutureWarning,
stacklevel=2,
)

Expand Down Expand Up @@ -374,6 +377,7 @@ def nearest_edges(G, X, Y, interpolate=None, return_dist=False):
warn(
"The `interpolate` parameter has been deprecated and will be "
"removed in the v2.0.0 release.",
FutureWarning,
stacklevel=2,
)

Expand Down Expand Up @@ -447,6 +451,7 @@ def shortest_path(G, orig, dest, weight="length", cpus=1):
warn(
"The `shortest_path` function has moved to the `routing` module. Calling it "
"via the `distance` module will raise an error starting in the v2.0.0 release.",
FutureWarning,
stacklevel=2,
)
return routing.shortest_path(G, orig, dest, weight, cpus)
Expand Down Expand Up @@ -482,6 +487,7 @@ def k_shortest_paths(G, orig, dest, k, weight="length"):
warn(
"The `k_shortest_paths` function has moved to the `routing` module. "
"Calling it via the `distance` module will raise an error in the v2.0.0 release.",
FutureWarning,
stacklevel=2,
)
return routing.k_shortest_paths(G, orig, dest, k, weight)
4 changes: 4 additions & 0 deletions osmnx/elevation.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def add_edge_grades(G, add_absolute=True, precision=None):
else:
warn(
"The `precision` parameter is deprecated and will be removed in the v2.0.0 release.",
FutureWarning,
stacklevel=2,
)

Expand Down Expand Up @@ -211,6 +212,7 @@ def add_node_elevations_google(
warn(
"The `max_locations_per_batch` parameter is deprecated and will be "
"removed the v2.0.0 release, use the `batch_size` parameter instead",
FutureWarning,
stacklevel=2,
)

Expand All @@ -219,6 +221,7 @@ def add_node_elevations_google(
else:
warn(
"The `precision` parameter is deprecated and will be removed in the v2.0.0 release.",
FutureWarning,
stacklevel=2,
)

Expand All @@ -229,6 +232,7 @@ def add_node_elevations_google(
"The `url_template` parameter is deprecated and will be removed "
"in the v2.0.0 release. Configure the `settings` module's "
"`elevation_url_template` instead",
FutureWarning,
stacklevel=2,
)

Expand Down
3 changes: 2 additions & 1 deletion osmnx/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def features_from_bbox(north=None, south=None, east=None, west=None, bbox=None,
"The `north`, `south`, `east`, and `west` parameters are deprecated and "
"will be removed in the v2.0.0 release. Use the `bbox` parameter instead."
)
warn(msg, stacklevel=2)
warn(msg, FutureWarning, stacklevel=2)
bbox = (north, south, east, west)

# convert bounding box to a polygon
Expand Down Expand Up @@ -270,6 +270,7 @@ def features_from_place(query, tags, which_result=None, buffer_dist=None):
warn(
"The buffer_dist argument has been deprecated and will be removed "
"in the v2.0.0 release. Buffer your query area directly, if desired.",
FutureWarning,
stacklevel=2,
)

Expand Down
2 changes: 2 additions & 0 deletions osmnx/folium.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def plot_graph_folium(
"and/or routes automatically using GeoPandas.GeoDataFrame.explore instead, "
"for example like: `ox.graph_to_gdfs(G, nodes=False).explore()`. See the "
"OSMnx examples gallery for complete details and demonstrations.",
FutureWarning,
stacklevel=2,
)
# create gdf of all graph edges
Expand Down Expand Up @@ -117,6 +118,7 @@ def plot_route_folium(
"and/or routes automatically using GeoPandas.GeoDataFrame.explore instead, "
"for example like: `ox.graph_to_gdfs(G, nodes=False).explore()`. See the "
"OSMnx examples gallery for complete details and demonstrations.",
FutureWarning,
stacklevel=2,
)
# create gdf of the route edges in order
Expand Down
1 change: 1 addition & 0 deletions osmnx/geocoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def geocode_to_gdf(query, which_result=None, by_osmid=False, buffer_dist=None):
warn(
"The buffer_dist argument has been deprecated and will be removed "
"in the v2.0.0 release. Buffer your results directly, if desired.",
FutureWarning,
stacklevel=2,
)

Expand Down
12 changes: 6 additions & 6 deletions osmnx/geometries.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def geometries_from_bbox(north, south, east, west, tags):
-------
gdf : geopandas.GeoDataFrame
"""
warn(DEP_MSG, stacklevel=2)
warn(DEP_MSG, FutureWarning, stacklevel=2)
return features.features_from_bbox(north, south, east, west, tags=tags)


Expand All @@ -69,7 +69,7 @@ def geometries_from_point(center_point, tags, dist=1000):
-------
gdf : geopandas.GeoDataFrame
"""
warn(DEP_MSG, stacklevel=2)
warn(DEP_MSG, FutureWarning, stacklevel=2)
return features.features_from_point(center_point, tags, dist)


Expand All @@ -95,7 +95,7 @@ def geometries_from_address(address, tags, dist=1000):
-------
gdf : geopandas.GeoDataFrame
"""
warn(DEP_MSG, stacklevel=2)
warn(DEP_MSG, FutureWarning, stacklevel=2)
return features.features_from_address(address, tags, dist)


Expand Down Expand Up @@ -123,7 +123,7 @@ def geometries_from_place(query, tags, which_result=None, buffer_dist=None):
-------
gdf : geopandas.GeoDataFrame
"""
warn(DEP_MSG, stacklevel=2)
warn(DEP_MSG, FutureWarning, stacklevel=2)
return features.features_from_place(query, tags, which_result, buffer_dist)


Expand All @@ -147,7 +147,7 @@ def geometries_from_polygon(polygon, tags):
-------
gdf : geopandas.GeoDataFrame
"""
warn(DEP_MSG, stacklevel=2)
warn(DEP_MSG, FutureWarning, stacklevel=2)
return features.features_from_polygon(polygon, tags)


Expand All @@ -173,5 +173,5 @@ def geometries_from_xml(filepath, polygon=None, tags=None):
-------
gdf : geopandas.GeoDataFrame
"""
warn(DEP_MSG, stacklevel=2)
warn(DEP_MSG, FutureWarning, stacklevel=2)
return features.features_from_xml(filepath, polygon, tags)
5 changes: 4 additions & 1 deletion osmnx/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def graph_from_bbox(
"The `north`, `south`, `east`, and `west` parameters are deprecated and "
"will be removed in the v2.0.0 release. Use the `bbox` parameter instead."
)
warn(msg, stacklevel=2)
warn(msg, FutureWarning, stacklevel=2)
bbox = (north, south, east, west)

# convert bounding box to a polygon
Expand Down Expand Up @@ -270,6 +270,7 @@ def graph_from_address(
"The `return_coords` argument has been deprecated and will be removed in "
"the v2.0.0 release. Future behavior will be as though `return_coords=False`. "
"If you want the address's geocoded coordinates, use the `geocode` function.",
FutureWarning,
stacklevel=2,
)
# geocode the address string to a (lat, lon) point
Expand Down Expand Up @@ -367,6 +368,7 @@ def graph_from_place(
warn(
"The buffer_dist argument has been deprecated and will be removed "
"in the v2.0.0 release. Buffer your query area directly, if desired.",
FutureWarning,
stacklevel=2,
)

Expand Down Expand Up @@ -458,6 +460,7 @@ def graph_from_polygon(
warn(
"The clean_periphery argument has been deprecated and will be removed in "
"the v2.0.0 release. Future behavior will be as though clean_periphery=True.",
FutureWarning,
stacklevel=2,
)

Expand Down
1 change: 1 addition & 0 deletions osmnx/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def save_graph_shapefile(G, filepath=None, encoding="utf-8", directed=False):
"The `save_graph_shapefile` function is deprecated and will be removed "
"in the v2.0.0 release. Instead, use the `save_graph_geopackage` function "
"to save graphs as GeoPackage files for subsequent GIS analysis.",
FutureWarning,
stacklevel=2,
)

Expand Down
1 change: 1 addition & 0 deletions osmnx/osm_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def save_graph_xml(
"The save_graph_xml function has moved from the osm_xml module to the io module. "
"osm_xml.save_graph_xml has been deprecated and will be removed in the v2.0.0 "
"release. Access the function via the io module instead.",
FutureWarning,
stacklevel=2,
)
_save_graph_xml(
Expand Down
9 changes: 5 additions & 4 deletions osmnx/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def get_colors(n, cmap="viridis", start=0.0, stop=1.0, alpha=1.0, return_hex=Fal
warn(
"The `return_hex` parameter has been deprecated and will be removed "
"in the v2.0.0 release.",
FutureWarning,
stacklevel=2,
)

Expand Down Expand Up @@ -483,7 +484,7 @@ def plot_figure_ground(
"The `edge_color` parameter is deprecated and will be removed in the "
"v2.0.0 release. Use `color` instead."
)
warn(msg, stacklevel=2)
warn(msg, FutureWarning, stacklevel=2)

if smooth_joints is None:
smooth_joints = True
Expand All @@ -492,7 +493,7 @@ def plot_figure_ground(
"The `smooth_joints` parameter is deprecated and will be removed in the "
"v2.0.0 release. In the future this function will behave as though True."
)
warn(msg, stacklevel=2)
warn(msg, FutureWarning, stacklevel=2)

# if user did not pass in custom street widths, create a dict of defaults
if street_widths is None:
Expand Down Expand Up @@ -522,7 +523,7 @@ def plot_figure_ground(
# dist multiplier to ensure we get more than enough network. simplify in
# non-strict mode to not combine multiple street types into single edge
elif address is not None:
warn(dep_msg, stacklevel=2)
warn(dep_msg, FutureWarning, stacklevel=2)
G, point = graph.graph_from_address(
address,
dist=dist * multiplier,
Expand All @@ -534,7 +535,7 @@ def plot_figure_ground(
)
G = simplification.simplify_graph(G, strict=False)
elif point is not None:
warn(dep_msg, stacklevel=2)
warn(dep_msg, FutureWarning, stacklevel=2)
G = graph.graph_from_point(
point,
dist=dist * multiplier,
Expand Down
2 changes: 2 additions & 0 deletions osmnx/speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def add_edge_speeds(G, hwy_speeds=None, fallback=None, precision=None, agg=np.me
else:
warn(
"The `precision` parameter is deprecated and will be removed in the v2.0.0 release.",
FutureWarning,
stacklevel=2,
)

Expand Down Expand Up @@ -151,6 +152,7 @@ def add_edge_travel_times(G, precision=None):
else:
warn(
"The `precision` parameter is deprecated and will be removed in the v2.0.0 release.",
FutureWarning,
stacklevel=2,
)

Expand Down
3 changes: 2 additions & 1 deletion osmnx/truncate.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def truncate_graph_bbox(
"The `north`, `south`, `east`, and `west` parameters are deprecated and "
"will be removed in the v2.0.0 release. Use the `bbox` parameter instead."
)
warn(msg, stacklevel=2)
warn(msg, FutureWarning, stacklevel=2)
bbox = (north, south, east, west)

# convert bounding box to a polygon, then truncate
Expand Down Expand Up @@ -157,6 +157,7 @@ def truncate_graph_polygon(
warn(
"The `quadrat_width` and `min_num` parameters are deprecated and "
"will be removed in the v2.0.0 release.",
FutureWarning,
stacklevel=2,
)

Expand Down
1 change: 1 addition & 0 deletions osmnx/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def config(
"the v2.0.0 release. Instead, use the `settings` module directly to "
"configure a global setting's value. For example, "
"`ox.settings.log_console=True`.",
FutureWarning,
stacklevel=2,
)

Expand Down
3 changes: 2 additions & 1 deletion osmnx/utils_geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def round_geometry_coords(geom, precision):
warn(
"The `round_geometry_coords` function is deprecated and will be "
"removed in the v2.0.0 release.",
FutureWarning,
stacklevel=2,
)

Expand Down Expand Up @@ -459,7 +460,7 @@ def bbox_to_poly(north=None, south=None, east=None, west=None, bbox=None):
"The `north`, `south`, `east`, and `west` parameters are deprecated and "
"will be removed in the v2.0.0 release. Use the `bbox` parameter instead."
)
warn(msg, stacklevel=2)
warn(msg, FutureWarning, stacklevel=2)
else:
north, south, east, west = bbox
return Polygon([(west, south), (east, south), (east, north), (west, north)])
1 change: 1 addition & 0 deletions osmnx/utils_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ def get_route_edge_attributes(
warn(
"The `get_route_edge_attributes` function has been deprecated and will "
"be removed in the v2.0.0 release. Use the `route_to_gdf` function instead.",
FutureWarning,
stacklevel=2,
)
attribute_values = []
Expand Down

0 comments on commit 77dc3b1

Please sign in to comment.