From 01e07f6eab743ca428ab8b36b405fae45e99140b Mon Sep 17 00:00:00 2001 From: Geoff Boeing Date: Fri, 24 Jan 2025 16:43:59 -0800 Subject: [PATCH] do not mutate passed-in graph --- osmnx/simplification.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osmnx/simplification.py b/osmnx/simplification.py index 06194d95..ca100873 100644 --- a/osmnx/simplification.py +++ b/osmnx/simplification.py @@ -335,7 +335,7 @@ def simplify_graph( # noqa: C901, PLR0912 Returns ------- - G + Gs Topologically simplified graph, with a new `geometry` attribute on each simplified edge. """ @@ -513,19 +513,19 @@ def consolidate_intersections( Returns ------- - G or gs + Gc or gs If `rebuild_graph=True`, returns MultiDiGraph with consolidated intersections and (optionally) reconnected edge geometries. If `rebuild_graph=False`, returns GeoSeries of Points representing the centroids of street intersections. """ + # make a copy to not mutate original graph object caller passed in + G = G.copy() + # if dead_ends is False, discard dead-ends to retain only intersections if not dead_ends: spn = stats.streets_per_node(G) dead_end_nodes = [node for node, count in spn.items() if count <= 1] - - # make a copy to not mutate original graph object caller passed in - G = G.copy() G.remove_nodes_from(dead_end_nodes) if rebuild_graph: