From 954aefc9f87638ca57e2db39d329a4f5b0e6a198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20L=2E=20Magalh=C3=A3es?= <pedro.magalhaes@uni-bremen.de> Date: Sun, 10 Dec 2023 22:32:50 +0100 Subject: [PATCH] Pre-merge. --- src/topupopt/data/gis/calculate.py | 2 +- src/topupopt/data/gis/identify.py | 6 ++---- src/topupopt/data/gis/modify.py | 6 ++---- src/topupopt/data/gis/utils.py | 5 +---- tests/test_gis_identify.py | 6 +++++- tests/test_gis_modify.py | 2 +- tests/test_gis_utils.py | 3 +-- 7 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/topupopt/data/gis/calculate.py b/src/topupopt/data/gis/calculate.py index ad236f7..03586a2 100644 --- a/src/topupopt/data/gis/calculate.py +++ b/src/topupopt/data/gis/calculate.py @@ -341,4 +341,4 @@ def count_ocurrences(gdf: GeoDataFrame, return count_dict # ***************************************************************************** -# ***************************************************************************** \ No newline at end of file +# ***************************************************************************** diff --git a/src/topupopt/data/gis/identify.py b/src/topupopt/data/gis/identify.py index 1449bac..33ccd46 100644 --- a/src/topupopt/data/gis/identify.py +++ b/src/topupopt/data/gis/identify.py @@ -1030,7 +1030,6 @@ def is_path_straight(network: nx.MultiDiGraph, # confirm that it is a path if not is_node_path(network, path, consider_reversed_edges): return False - # a straight path requires at least two nodes path_length = len(path) if path_length == 2: @@ -1161,7 +1160,6 @@ def find_simplifiable_paths(network: nx.MultiDiGraph, if consider_reversed_edges and include_both_directions: # directions do not matter: list_paths.append(new_sequence[::-1]) - # update the list of intermediate nodes already on paths list_nodes_joined.update(set(new_sequence[1:-1])) @@ -1308,7 +1306,7 @@ def _find_path_direction_sensitive( ) # cycles have to be detected on the first try if len(path) >= 3 and path[0] == path[-1]: - # it is a cycle: no need to seedgeh backwards + # it is a cycle: no need to search backwards return path # find the backward path segment return find_path_backward( @@ -1733,4 +1731,4 @@ def identify_edge_closest_to_node( return nearest_edge_keys, projected_network # ***************************************************************************** -# ***************************************************************************** \ No newline at end of file +# ***************************************************************************** diff --git a/src/topupopt/data/gis/modify.py b/src/topupopt/data/gis/modify.py index 97990b5..4bb3c58 100644 --- a/src/topupopt/data/gis/modify.py +++ b/src/topupopt/data/gis/modify.py @@ -378,7 +378,6 @@ def replace_path( edge_length = 0 for node_pair_index in range(len(path)-1): - # get one edge for this node pair edge_key = list(gis_iden.get_edges_between_two_nodes( network, @@ -388,8 +387,7 @@ def replace_path( edge_key = sorted( (network.edges[_key][osm.KEY_OSMNX_LENGTH], _key) for _key in edge_key - )[0][1] - + )[0][1] if osm.KEY_OSMNX_GEOMETRY in network.edges[edge_key]: # geometry exists: possibly a composite geometry # check if the geometry is consistent with the edge declaration @@ -1388,4 +1386,4 @@ def create_reverse_edges( return edges_created # ***************************************************************************** -# ***************************************************************************** \ No newline at end of file +# ***************************************************************************** diff --git a/src/topupopt/data/gis/utils.py b/src/topupopt/data/gis/utils.py index bd64e2e..3ad38ee 100644 --- a/src/topupopt/data/gis/utils.py +++ b/src/topupopt/data/gis/utils.py @@ -1024,7 +1024,6 @@ def identify_building_entrance_edges( # otherwise, the edge is nameless but may not lead to the right street # get adjacent/neighbouring edges - other_edges = gis_iden.get_edges_involving_node( network=network, node_key=closest_edge_key[0], @@ -1214,9 +1213,7 @@ def convert_edge_path(network: MultiDiGraph, # path is a sequence of edge keys: convert to node path if allow_reversed_edges: - # reverse edges are allowed - # drop self-loops, if any edge_path = [ edge_key @@ -1261,4 +1258,4 @@ def convert_edge_path(network: MultiDiGraph, return node_path # ***************************************************************************** -# ***************************************************************************** \ No newline at end of file +# ***************************************************************************** diff --git a/tests/test_gis_identify.py b/tests/test_gis_identify.py index 0486809..1d62f7c 100644 --- a/tests/test_gis_identify.py +++ b/tests/test_gis_identify.py @@ -30,7 +30,7 @@ class TestGisIdentify: path: list, excluded_nodes: list, consider_reversed_edges: bool, - ignore_self_loops: bool): + ignore_self_loops: bool): # find out the unique nodes set_nodes = set(path) # at least three nodes @@ -4542,6 +4542,10 @@ class TestGisIdentify: # ************************************************************************* # ************************************************************************* +<<<<<<< HEAD +#****************************************************************************** +#****************************************************************************** +======= def test_finding_roundabouts(self): # network should be a OSM-nx formatted graph diff --git a/tests/test_gis_modify.py b/tests/test_gis_modify.py index a6b7181..a7bb81e 100644 --- a/tests/test_gis_modify.py +++ b/tests/test_gis_modify.py @@ -3274,4 +3274,4 @@ class TestGisModify: # TODO: test the conversion itself # ***************************************************************************** -# ***************************************************************************** \ No newline at end of file +# ***************************************************************************** diff --git a/tests/test_gis_utils.py b/tests/test_gis_utils.py index 19c6040..ea06e9e 100644 --- a/tests/test_gis_utils.py +++ b/tests/test_gis_utils.py @@ -944,7 +944,6 @@ class TestGisUtils: country_code=country_code) # find out which is the closest edge - nearest_edge_keys, network = gis_iden.identify_edge_closest_to_node( network, node_keys=['P']) @@ -2143,4 +2142,4 @@ class TestGisUtils: # ************************************************************************* # ***************************************************************************** -# ***************************************************************************** \ No newline at end of file +# ***************************************************************************** -- GitLab