Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate functionality that was moved or renamed for v2.0.0 #1146

Merged
merged 11 commits into from
Mar 15, 2024
Prev Previous commit
Next Next commit
rename edge_attrs to edge_attrs_differ
gboeing committed Mar 13, 2024
commit 71066f357262303ce5018302176edabd8632b6f0
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

- deprecate settings module's renamed or obsolete settings (#1138)
- deprecate save_graph_xml function's renamed or obsolete parameters (#1138)
- deprecate simplify_graph function's endpoint_attrs argument: renamed to edge_attrs (#1146)
- deprecate simplify_graph function's endpoint_attrs argument: renamed to edge_attrs_differ (#1146)

## 1.9.1 (2024-02-01)

31 changes: 18 additions & 13 deletions osmnx/simplification.py
Original file line number Diff line number Diff line change
@@ -229,7 +229,12 @@ def _remove_rings(G, endpoint_attrs):


def simplify_graph( # noqa: C901
G, strict=None, edge_attrs=None, endpoint_attrs=None, remove_rings=True, track_merged=False
G,
strict=None,
edge_attrs_differ=None,
endpoint_attrs=None,
remove_rings=True,
track_merged=False,
):
"""
Simplify a graph's topology by removing interstitial nodes.
@@ -245,8 +250,8 @@ def simplify_graph( # noqa: C901
simplified edges can receive a `merged_edges` attribute that contains a
list of all the (u, v) node pairs that were merged together.

Use the `edge_attrs` parameter to relax simplification strictness. For
example, `edge_attrs=['osmid']` will retain every node whose incident
Use the `edge_attrs_differ` parameter to relax simplification strictness. For
example, `edge_attrs_differ=['osmid']` will retain every node whose incident
edges have different OSM IDs. This lets you keep nodes at elbow two-way
intersections (but be aware that sometimes individual blocks have multiple
OSM IDs within them too). You could also use this parameter to retain
@@ -258,11 +263,11 @@ def simplify_graph( # noqa: C901
input graph
strict : bool
deprecated, do not use
edge_attrs : iterable
edge_attrs_differ : iterable
An iterable of edge attribute names for relaxing the strictness of
endpoint determination. If not None, a node is an endpoint if its
incident edges have different values then each other for any of the
edge attributes in `edge_attrs`.
edge attributes in `edge_attrs_differ`.
endpoint_attrs : iterable
deprecated, do not use
remove_rings : bool
@@ -280,22 +285,22 @@ def simplify_graph( # noqa: C901
if endpoint_attrs is not None:
msg = (
"The `endpoint_attrs` parameter has been deprecated and will be removed "
"in the v2.0.0 release. Use the `edge_attrs` parameter instead."
"in the v2.0.0 release. Use the `edge_attrs_differ` parameter instead."
)
warn(msg, FutureWarning, stacklevel=2)
edge_attrs = endpoint_attrs
edge_attrs_differ = endpoint_attrs

if strict is not None:
msg = (
"The `strict` parameter has been deprecated and will be removed in "
"the v2.0.0 release. Use the `edge_attrs` parameter instead to "
"relax simplification strictness. For example, `edge_attrs=None` "
"reproduces the old `strict=True` behvavior and `edge_attrs=['osmid']` "
"the v2.0.0 release. Use the `edge_attrs_differ` parameter instead to "
"relax simplification strictness. For example, `edge_attrs_differ=None` "
"reproduces the old `strict=True` behvavior and `edge_attrs_differ=['osmid']` "
"reproduces the old `strict=False` behavior."
)
warn(msg, FutureWarning, stacklevel=2)
# maintain old behavior if strict is passed during deprecation
edge_attrs = None if strict else ["osmid"]
edge_attrs_differ = None if strict else ["osmid"]

if "simplified" in G.graph and G.graph["simplified"]: # pragma: no cover
msg = "This graph has already been simplified, cannot simplify it again."
@@ -314,7 +319,7 @@ def simplify_graph( # noqa: C901
all_edges_to_add = []

# generate each path that needs to be simplified
for path in _get_paths_to_simplify(G, edge_attrs):
for path in _get_paths_to_simplify(G, edge_attrs_differ):
# add the interstitial edges we're removing to a list so we can retain
# their spatial geometry
merged_edges = []
@@ -384,7 +389,7 @@ def simplify_graph( # noqa: C901
G.remove_nodes_from(set(all_nodes_to_remove))

if remove_rings:
G = _remove_rings(G, edge_attrs)
G = _remove_rings(G, edge_attrs_differ)

# mark the graph as having been simplified
G.graph["simplified"] = True