Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • master
1 result

Target

Select target project
  • pmag/topupopt
1 result
Select Git revision
  • master
1 result
Show changes
...@@ -85,6 +85,8 @@ class TestTimeFrame: ...@@ -85,6 +85,8 @@ class TestTimeFrame:
assert tf.number_reporting_periods(0) == 3 assert tf.number_reporting_periods(0) == 3
# number of time intervals # number of time intervals
assert tf.number_time_intervals(0) == 2 assert tf.number_time_intervals(0) == 2
# no overlapping assessments
assert not tf.assessments_overlap()
# q: valid # q: valid
assert tf.valid_q(reporting_periods) assert tf.valid_q(reporting_periods)
...@@ -200,6 +202,28 @@ class TestTimeFrame: ...@@ -200,6 +202,28 @@ class TestTimeFrame:
assert not tf.complete_qpk( assert not tf.complete_qpk(
{(0, 0, 0): 1, (0, 0, 1): 1, (0, 1, 0): 1, (0, 1, 1): 1} {(0, 0, 0): 1, (0, 0, 1): 1, (0, 1, 0): 1, (0, 1, 1): 1}
) )
# qpk: consecutive
assert tf.consecutive_qpk(
{
(0, 0, 0): 1,
(0, 0, 1): 1,
(0, 1, 0): 1,
(0, 1, 1): 1,
(0, 2, 0): 1,
(0, 2, 1): 1,
}
)
# qpk: not consecutive
assert not tf.consecutive_qpk(
{
(0, 0, 0): 1,
(0, 0, 1): 1,
(0, 1, 1): 1,
(0, 1, 2): 1,
(0, 2, 0): 1,
(0, 2, 1): 1,
}
)
qk_dict = {qk: None for qk in tf.qk()} qk_dict = {qk: None for qk in tf.qk()}
qp_dict = {qp: None for qp in tf.qp()} qp_dict = {qp: None for qp in tf.qp()}
...@@ -243,6 +267,8 @@ class TestTimeFrame: ...@@ -243,6 +267,8 @@ class TestTimeFrame:
# number of time intervals # number of time intervals
assert tf.number_time_intervals(0) == 2 assert tf.number_time_intervals(0) == 2
assert tf.number_time_intervals(1) == 2 assert tf.number_time_intervals(1) == 2
# no overlapping assessments
assert not tf.assessments_overlap()
# q: valid # q: valid
assert tf.valid_q(reporting_periods) assert tf.valid_q(reporting_periods)
...@@ -353,6 +379,28 @@ class TestTimeFrame: ...@@ -353,6 +379,28 @@ class TestTimeFrame:
assert not tf.complete_qpk( assert not tf.complete_qpk(
{(0, 0, 0): 1, (0, 0, 1): 1, (1, 1, 0): 1, (1, 1, 1): 1} {(0, 0, 0): 1, (0, 0, 1): 1, (1, 1, 0): 1, (1, 1, 1): 1}
) )
# qpk: consecutive
assert tf.consecutive_qpk(
{
(0, 0, 0): 1,
(0, 0, 1): 1,
(1, 1, 0): 1,
(1, 1, 1): 1,
(1, 2, 0): 1,
(1, 2, 1): 1,
}
)
# qpk: not consecutive
assert not tf.consecutive_qpk(
{
(0, 0, 0): 1,
(0, 0, 3): 1,
(1, 1, 0): 1,
(1, 1, 1): 1,
(1, 2, 0): 1,
(1, 2, 1): 1,
}
)
qk_dict = {qk: None for qk in tf.qk()} qk_dict = {qk: None for qk in tf.qk()}
qp_dict = {qp: None for qp in tf.qp()} qp_dict = {qp: None for qp in tf.qp()}
...@@ -390,6 +438,8 @@ class TestTimeFrame: ...@@ -390,6 +438,8 @@ class TestTimeFrame:
assert not tf.valid_q({2: 1}) assert not tf.valid_q({2: 1})
assert tf.complete_q(reporting_periods) assert tf.complete_q(reporting_periods)
assert not tf.complete_q({1: [365 * 24 * 3600]}) assert not tf.complete_q({1: [365 * 24 * 3600]})
# no overlapping assessments
assert not tf.assessments_overlap()
# qk: valid # qk: valid
assert tf.valid_qk( assert tf.valid_qk(
...@@ -501,6 +551,30 @@ class TestTimeFrame: ...@@ -501,6 +551,30 @@ class TestTimeFrame:
(1, 2, 1): 1, (1, 2, 1): 1,
} }
) )
# qpk: consecutive
assert tf.consecutive_qpk(
{
(0, 0, 0): 1,
(0, 0, 1): 1,
(0, 1, 0): 1,
(0, 1, 1): 1,
(1, 2, 0): 1,
(1, 2, 1): 1,
(1, 2, 2): 1,
}
)
# qpk: not consecutive
assert not tf.consecutive_qpk(
{
(0, 0, 0): 1,
(0, 0, 1): 1,
(0, 1, 0): 1,
(0, 1, 1): 1,
(1, 2, 0): 1,
(1, 2, 1): 1,
(1, 2, 3): 1,
}
)
qk_dict = {qk: None for qk in tf.qk()} qk_dict = {qk: None for qk in tf.qk()}
qp_dict = {qp: None for qp in tf.qp()} qp_dict = {qp: None for qp in tf.qp()}
...@@ -541,6 +615,8 @@ class TestTimeFrame: ...@@ -541,6 +615,8 @@ class TestTimeFrame:
# number of time intervals # number of time intervals
assert tf.number_time_intervals(0) == 2 assert tf.number_time_intervals(0) == 2
assert tf.number_time_intervals(1) == 2 assert tf.number_time_intervals(1) == 2
# assessments overlap
assert tf.assessments_overlap()
# q: valid # q: valid
assert tf.valid_q(reporting_periods) assert tf.valid_q(reporting_periods)
...@@ -664,6 +740,40 @@ class TestTimeFrame: ...@@ -664,6 +740,40 @@ class TestTimeFrame:
(1, 2, 1): 1, (1, 2, 1): 1,
} }
) )
# qpk: consecutive
assert tf.consecutive_qpk(
{
(0, 0, 0): 1,
(0, 0, 1): 1,
(0, 1, 0): 1,
(0, 1, 1): 1,
(0, 2, 0): 1,
(0, 2, 1): 1,
(1, 0, 0): 1,
(1, 0, 1): 1,
(1, 1, 0): 1,
(1, 1, 1): 1,
(1, 2, 0): 1,
(1, 2, 1): 1,
}
)
# qpk: not consecutive
assert not tf.consecutive_qpk(
{
(0, 0, 0): 1,
(0, 0, 1): 1,
(0, 1, 0): 1,
(0, 1, 1): 1,
(0, 2, 0): 1,
(0, 2, 2): 1,
(1, 0, 0): 1,
(1, 0, 1): 1,
(1, 1, 0): 1,
(1, 1, 1): 1,
(1, 2, 0): 1,
(1, 2, 1): 1,
}
)
qk_dict = {qk: None for qk in tf.qk()} qk_dict = {qk: None for qk in tf.qk()}
qp_dict = {qp: None for qp in tf.qp()} qp_dict = {qp: None for qp in tf.qp()}
...@@ -737,6 +847,8 @@ class TestTimeFrame: ...@@ -737,6 +847,8 @@ class TestTimeFrame:
assert tf.number_time_intervals(3) == 2 assert tf.number_time_intervals(3) == 2
assert tf.number_time_intervals(4) == 2 assert tf.number_time_intervals(4) == 2
assert tf.number_time_intervals(5) == 2 assert tf.number_time_intervals(5) == 2
# assessments overlap
assert tf.assessments_overlap()
# q: valid # q: valid
assert tf.valid_q(reporting_periods) assert tf.valid_q(reporting_periods)
...@@ -895,6 +1007,40 @@ class TestTimeFrame: ...@@ -895,6 +1007,40 @@ class TestTimeFrame:
# (5, 2, 1): 1, # (5, 2, 1): 1,
} }
) )
# qpk: consecutive
assert tf.consecutive_qpk(
{
(0, 0, 0): 1,
(1, 0, 0): 1,
(2, 1, 0): 1,
(3, 1, 0): 1,
(4, 2, 0): 1,
(5, 2, 0): 1,
(0, 0, 1): 1,
(1, 0, 1): 1,
(2, 1, 1): 1,
(3, 1, 1): 1,
(4, 2, 1): 1,
(5, 2, 1): 1,
}
)
# qpk: not consecutive
assert not tf.consecutive_qpk(
{
(0, 0, 0): 1,
(1, 0, 0): 1,
(2, 1, 0): 1,
(3, 1, 0): 1,
(4, 2, 0): 1,
(5, 2, 0): 1,
(0, 0, 2): 1,
(1, 0, 1): 1,
(2, 1, 1): 1,
(3, 1, 1): 1,
(4, 2, 1): 1,
(5, 2, 1): 1,
}
)
qk_dict = {qk: None for qk in tf.qk()} qk_dict = {qk: None for qk in tf.qk()}
qp_dict = {qp: None for qp in tf.qp()} qp_dict = {qp: None for qp in tf.qp()}
...@@ -1114,5 +1260,32 @@ class TestTimeFrame: ...@@ -1114,5 +1260,32 @@ class TestTimeFrame:
for df, true_df in zip(factors, true_factors): for df, true_df in zip(factors, true_factors):
assert isclose(df, true_df, abs_tol=0.001) assert isclose(df, true_df, abs_tol=0.001)
# *************************************************************************
# *************************************************************************
def test_etf_unrecognised_input(self):
# define the discount rate using a set
error_raised = False
try:
EconomicTimeFrame(
discount_rate={0.035},
reporting_periods={
0: [0,1,2,3]
},
reporting_period_durations={
0: [1,1,1,1]
},
time_intervals={
0: [0]
},
time_interval_durations={
0: [1]
},
)
except TypeError:
error_raised = True
assert error_raised
# ***************************************************************************** # *****************************************************************************
# ***************************************************************************** # *****************************************************************************
...@@ -51,5 +51,8 @@ class TestProblemUtils: ...@@ -51,5 +51,8 @@ class TestProblemUtils:
error_raised = True error_raised = True
assert error_raised assert error_raised
# *************************************************************************
# *************************************************************************
# ***************************************************************************** # *****************************************************************************
# ***************************************************************************** # *****************************************************************************
...@@ -28,7 +28,7 @@ class TestGisIdentify: ...@@ -28,7 +28,7 @@ class TestGisIdentify:
self, self,
network: nx.MultiDiGraph, network: nx.MultiDiGraph,
path: list, path: list,
excluded_nodes: list, protected_nodes: list,
consider_reversed_edges: bool, consider_reversed_edges: bool,
ignore_self_loops: bool, ignore_self_loops: bool,
): ):
...@@ -48,7 +48,7 @@ class TestGisIdentify: ...@@ -48,7 +48,7 @@ class TestGisIdentify:
assert path[0] == path[-1] and path[0] == node assert path[0] == path[-1] and path[0] == node
# cycle: make sure # cycle: make sure
# no excluded nodes in the intermediate positions # no excluded nodes in the intermediate positions
for node in excluded_nodes: for node in protected_nodes:
assert node not in path[1:-1] assert node not in path[1:-1]
# intermediate nodes can only have two neighbours # intermediate nodes can only have two neighbours
for node_key in path[1:-1]: for node_key in path[1:-1]:
...@@ -119,7 +119,7 @@ class TestGisIdentify: ...@@ -119,7 +119,7 @@ class TestGisIdentify:
# paths # paths
paths = gis_iden.find_simplifiable_paths( paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes=[], protected_nodes=[],
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -128,7 +128,7 @@ class TestGisIdentify: ...@@ -128,7 +128,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
path, path,
excluded_nodes=[], protected_nodes=[],
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -142,7 +142,7 @@ class TestGisIdentify: ...@@ -142,7 +142,7 @@ class TestGisIdentify:
# paths # paths
paths = gis_iden.find_simplifiable_paths( paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes=[], protected_nodes=[],
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -151,7 +151,7 @@ class TestGisIdentify: ...@@ -151,7 +151,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
path, path,
excluded_nodes=[], protected_nodes=[],
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -165,7 +165,7 @@ class TestGisIdentify: ...@@ -165,7 +165,7 @@ class TestGisIdentify:
# paths # paths
paths = gis_iden.find_simplifiable_paths( paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes=[], protected_nodes=[],
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -174,7 +174,7 @@ class TestGisIdentify: ...@@ -174,7 +174,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
path, path,
excluded_nodes=[], protected_nodes=[],
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -188,7 +188,7 @@ class TestGisIdentify: ...@@ -188,7 +188,7 @@ class TestGisIdentify:
# paths # paths
paths = gis_iden.find_simplifiable_paths( paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes=[], protected_nodes=[],
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -197,7 +197,7 @@ class TestGisIdentify: ...@@ -197,7 +197,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
path, path,
excluded_nodes=[], protected_nodes=[],
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -223,7 +223,7 @@ class TestGisIdentify: ...@@ -223,7 +223,7 @@ class TestGisIdentify:
# no reversed edges, no self loops, no excluded nodes # no reversed edges, no self loops, no excluded nodes
consider_reversed_edges = False consider_reversed_edges = False
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
# test path validator with non-path # test path validator with non-path
error_raised = False error_raised = False
...@@ -231,7 +231,7 @@ class TestGisIdentify: ...@@ -231,7 +231,7 @@ class TestGisIdentify:
assert not self.straight_path_validator( assert not self.straight_path_validator(
network, network,
[1, 1, 1], [1, 1, 1],
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -241,7 +241,7 @@ class TestGisIdentify: ...@@ -241,7 +241,7 @@ class TestGisIdentify:
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -255,11 +255,11 @@ class TestGisIdentify: ...@@ -255,11 +255,11 @@ class TestGisIdentify:
# no reversed edges, no self loops, no excluded nodes # no reversed edges, no self loops, no excluded nodes
consider_reversed_edges = False consider_reversed_edges = False
ignore_self_loops = True ignore_self_loops = True
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -276,11 +276,11 @@ class TestGisIdentify: ...@@ -276,11 +276,11 @@ class TestGisIdentify:
# no reversed edges, no self loops, no excluded nodes # no reversed edges, no self loops, no excluded nodes
consider_reversed_edges = True consider_reversed_edges = True
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -297,11 +297,11 @@ class TestGisIdentify: ...@@ -297,11 +297,11 @@ class TestGisIdentify:
# no reversed edges, no self loops, no excluded nodes # no reversed edges, no self loops, no excluded nodes
consider_reversed_edges = True consider_reversed_edges = True
ignore_self_loops = True ignore_self_loops = True
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -343,11 +343,11 @@ class TestGisIdentify: ...@@ -343,11 +343,11 @@ class TestGisIdentify:
# no reversed edges, no self loops, no excluded nodes # no reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -359,11 +359,11 @@ class TestGisIdentify: ...@@ -359,11 +359,11 @@ class TestGisIdentify:
# no reversed edges, allow self loops, no excluded nodes # no reversed edges, allow self loops, no excluded nodes
ignore_self_loops = True ignore_self_loops = True
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -375,11 +375,11 @@ class TestGisIdentify: ...@@ -375,11 +375,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the middle node # do not allow reversed edges, no self loops, excluded the middle node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [1] protected_nodes = [1]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -391,11 +391,11 @@ class TestGisIdentify: ...@@ -391,11 +391,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the start node # do not allow reversed edges, no self loops, excluded the start node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [0] protected_nodes = [0]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -407,11 +407,11 @@ class TestGisIdentify: ...@@ -407,11 +407,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the end node # do not allow reversed edges, no self loops, excluded the end node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [2] protected_nodes = [2]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -429,11 +429,11 @@ class TestGisIdentify: ...@@ -429,11 +429,11 @@ class TestGisIdentify:
# allow reversed edges, allow self loops, no excluded nodes # allow reversed edges, allow self loops, no excluded nodes
ignore_self_loops = True ignore_self_loops = True
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -445,11 +445,11 @@ class TestGisIdentify: ...@@ -445,11 +445,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, no excluded nodes # allow reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -461,11 +461,11 @@ class TestGisIdentify: ...@@ -461,11 +461,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the middle node # allow reversed edges, no self loops, excluded the middle node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [1] protected_nodes = [1]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -477,11 +477,11 @@ class TestGisIdentify: ...@@ -477,11 +477,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the start node # allow reversed edges, no self loops, excluded the start node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [0] protected_nodes = [0]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -493,11 +493,11 @@ class TestGisIdentify: ...@@ -493,11 +493,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the end node # allow reversed edges, no self loops, excluded the end node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [2] protected_nodes = [2]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -529,11 +529,11 @@ class TestGisIdentify: ...@@ -529,11 +529,11 @@ class TestGisIdentify:
# no reversed edges, no self loops, no excluded nodes # no reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -545,11 +545,11 @@ class TestGisIdentify: ...@@ -545,11 +545,11 @@ class TestGisIdentify:
# no reversed edges, allow self loops, no excluded nodes # no reversed edges, allow self loops, no excluded nodes
ignore_self_loops = True ignore_self_loops = True
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -561,11 +561,11 @@ class TestGisIdentify: ...@@ -561,11 +561,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the middle node # do not allow reversed edges, no self loops, excluded the middle node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [1] protected_nodes = [1]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -577,11 +577,11 @@ class TestGisIdentify: ...@@ -577,11 +577,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the start node # do not allow reversed edges, no self loops, excluded the start node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [0] protected_nodes = [0]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -593,11 +593,11 @@ class TestGisIdentify: ...@@ -593,11 +593,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the end node # do not allow reversed edges, no self loops, excluded the end node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [2] protected_nodes = [2]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -615,11 +615,11 @@ class TestGisIdentify: ...@@ -615,11 +615,11 @@ class TestGisIdentify:
# allow reversed edges, allow self loops, no excluded nodes # allow reversed edges, allow self loops, no excluded nodes
ignore_self_loops = True ignore_self_loops = True
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -631,11 +631,11 @@ class TestGisIdentify: ...@@ -631,11 +631,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, no excluded nodes # allow reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -647,11 +647,11 @@ class TestGisIdentify: ...@@ -647,11 +647,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the middle node # allow reversed edges, no self loops, excluded the middle node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [1] protected_nodes = [1]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -663,11 +663,11 @@ class TestGisIdentify: ...@@ -663,11 +663,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the start node # allow reversed edges, no self loops, excluded the start node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [0] protected_nodes = [0]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -679,11 +679,11 @@ class TestGisIdentify: ...@@ -679,11 +679,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the end node # allow reversed edges, no self loops, excluded the end node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [2] protected_nodes = [2]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -715,11 +715,11 @@ class TestGisIdentify: ...@@ -715,11 +715,11 @@ class TestGisIdentify:
# no reversed edges, no self loops, no excluded nodes # no reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -730,7 +730,7 @@ class TestGisIdentify: ...@@ -730,7 +730,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -740,11 +740,11 @@ class TestGisIdentify: ...@@ -740,11 +740,11 @@ class TestGisIdentify:
# no reversed edges, allow self loops, no excluded nodes # no reversed edges, allow self loops, no excluded nodes
ignore_self_loops = True ignore_self_loops = True
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -755,7 +755,7 @@ class TestGisIdentify: ...@@ -755,7 +755,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -765,11 +765,11 @@ class TestGisIdentify: ...@@ -765,11 +765,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the middle node # do not allow reversed edges, no self loops, excluded the middle node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [1] protected_nodes = [1]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -781,11 +781,11 @@ class TestGisIdentify: ...@@ -781,11 +781,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the start node # do not allow reversed edges, no self loops, excluded the start node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [0] protected_nodes = [0]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -796,7 +796,7 @@ class TestGisIdentify: ...@@ -796,7 +796,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -806,11 +806,11 @@ class TestGisIdentify: ...@@ -806,11 +806,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the end node # do not allow reversed edges, no self loops, excluded the end node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [2] protected_nodes = [2]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -821,7 +821,7 @@ class TestGisIdentify: ...@@ -821,7 +821,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -837,11 +837,11 @@ class TestGisIdentify: ...@@ -837,11 +837,11 @@ class TestGisIdentify:
# allow reversed edges, allow self loops, no excluded nodes # allow reversed edges, allow self loops, no excluded nodes
ignore_self_loops = True ignore_self_loops = True
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -852,7 +852,7 @@ class TestGisIdentify: ...@@ -852,7 +852,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -862,11 +862,11 @@ class TestGisIdentify: ...@@ -862,11 +862,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, no excluded nodes # allow reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -877,7 +877,7 @@ class TestGisIdentify: ...@@ -877,7 +877,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -887,11 +887,11 @@ class TestGisIdentify: ...@@ -887,11 +887,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the middle node # allow reversed edges, no self loops, excluded the middle node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [1] protected_nodes = [1]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -903,11 +903,11 @@ class TestGisIdentify: ...@@ -903,11 +903,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the start node # allow reversed edges, no self loops, excluded the start node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [0] protected_nodes = [0]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -918,7 +918,7 @@ class TestGisIdentify: ...@@ -918,7 +918,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -928,11 +928,11 @@ class TestGisIdentify: ...@@ -928,11 +928,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the end node # allow reversed edges, no self loops, excluded the end node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [2] protected_nodes = [2]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -943,7 +943,7 @@ class TestGisIdentify: ...@@ -943,7 +943,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -973,11 +973,11 @@ class TestGisIdentify: ...@@ -973,11 +973,11 @@ class TestGisIdentify:
# no reversed edges, no self loops, no excluded nodes # no reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -988,7 +988,7 @@ class TestGisIdentify: ...@@ -988,7 +988,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -998,11 +998,11 @@ class TestGisIdentify: ...@@ -998,11 +998,11 @@ class TestGisIdentify:
# no reversed edges, allow self loops, no excluded nodes # no reversed edges, allow self loops, no excluded nodes
ignore_self_loops = True ignore_self_loops = True
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1013,7 +1013,7 @@ class TestGisIdentify: ...@@ -1013,7 +1013,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1023,11 +1023,11 @@ class TestGisIdentify: ...@@ -1023,11 +1023,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the middle node # do not allow reversed edges, no self loops, excluded the middle node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [1] protected_nodes = [1]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1039,11 +1039,11 @@ class TestGisIdentify: ...@@ -1039,11 +1039,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the start node # do not allow reversed edges, no self loops, excluded the start node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [0] protected_nodes = [0]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1054,7 +1054,7 @@ class TestGisIdentify: ...@@ -1054,7 +1054,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1064,11 +1064,11 @@ class TestGisIdentify: ...@@ -1064,11 +1064,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the end node # do not allow reversed edges, no self loops, excluded the end node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [2] protected_nodes = [2]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1079,7 +1079,7 @@ class TestGisIdentify: ...@@ -1079,7 +1079,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1095,11 +1095,11 @@ class TestGisIdentify: ...@@ -1095,11 +1095,11 @@ class TestGisIdentify:
# allow reversed edges, allow self loops, no excluded nodes # allow reversed edges, allow self loops, no excluded nodes
ignore_self_loops = True ignore_self_loops = True
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1110,7 +1110,7 @@ class TestGisIdentify: ...@@ -1110,7 +1110,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1120,11 +1120,11 @@ class TestGisIdentify: ...@@ -1120,11 +1120,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, no excluded nodes # allow reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1135,7 +1135,7 @@ class TestGisIdentify: ...@@ -1135,7 +1135,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1145,11 +1145,11 @@ class TestGisIdentify: ...@@ -1145,11 +1145,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the middle node # allow reversed edges, no self loops, excluded the middle node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [1] protected_nodes = [1]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1161,11 +1161,11 @@ class TestGisIdentify: ...@@ -1161,11 +1161,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the start node # allow reversed edges, no self loops, excluded the start node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [0] protected_nodes = [0]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1176,7 +1176,7 @@ class TestGisIdentify: ...@@ -1176,7 +1176,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1186,11 +1186,11 @@ class TestGisIdentify: ...@@ -1186,11 +1186,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the end node # allow reversed edges, no self loops, excluded the end node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [2] protected_nodes = [2]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1201,7 +1201,7 @@ class TestGisIdentify: ...@@ -1201,7 +1201,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1231,11 +1231,11 @@ class TestGisIdentify: ...@@ -1231,11 +1231,11 @@ class TestGisIdentify:
# no self loops, no excluded nodes # no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1246,7 +1246,7 @@ class TestGisIdentify: ...@@ -1246,7 +1246,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1256,11 +1256,11 @@ class TestGisIdentify: ...@@ -1256,11 +1256,11 @@ class TestGisIdentify:
# allow self loops, no excluded nodes # allow self loops, no excluded nodes
ignore_self_loops = True ignore_self_loops = True
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1271,7 +1271,7 @@ class TestGisIdentify: ...@@ -1271,7 +1271,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1281,11 +1281,11 @@ class TestGisIdentify: ...@@ -1281,11 +1281,11 @@ class TestGisIdentify:
# no self loops, excluded the "middle" node # no self loops, excluded the "middle" node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [1] protected_nodes = [1]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1296,7 +1296,7 @@ class TestGisIdentify: ...@@ -1296,7 +1296,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1306,11 +1306,11 @@ class TestGisIdentify: ...@@ -1306,11 +1306,11 @@ class TestGisIdentify:
# no self loops, excluded the start node # no self loops, excluded the start node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [0] protected_nodes = [0]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1321,7 +1321,7 @@ class TestGisIdentify: ...@@ -1321,7 +1321,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1331,11 +1331,11 @@ class TestGisIdentify: ...@@ -1331,11 +1331,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the end node # do not allow reversed edges, no self loops, excluded the end node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [2] protected_nodes = [2]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1346,7 +1346,7 @@ class TestGisIdentify: ...@@ -1346,7 +1346,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1362,11 +1362,11 @@ class TestGisIdentify: ...@@ -1362,11 +1362,11 @@ class TestGisIdentify:
# allow reversed edges, allow self loops, no excluded nodes # allow reversed edges, allow self loops, no excluded nodes
ignore_self_loops = True ignore_self_loops = True
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1377,7 +1377,7 @@ class TestGisIdentify: ...@@ -1377,7 +1377,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1387,11 +1387,11 @@ class TestGisIdentify: ...@@ -1387,11 +1387,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, no excluded nodes # allow reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1402,7 +1402,7 @@ class TestGisIdentify: ...@@ -1402,7 +1402,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1412,11 +1412,11 @@ class TestGisIdentify: ...@@ -1412,11 +1412,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the middle node # allow reversed edges, no self loops, excluded the middle node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [1] protected_nodes = [1]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1427,7 +1427,7 @@ class TestGisIdentify: ...@@ -1427,7 +1427,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1437,11 +1437,11 @@ class TestGisIdentify: ...@@ -1437,11 +1437,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the start node # allow reversed edges, no self loops, excluded the start node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [0] protected_nodes = [0]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1452,7 +1452,7 @@ class TestGisIdentify: ...@@ -1452,7 +1452,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1462,11 +1462,11 @@ class TestGisIdentify: ...@@ -1462,11 +1462,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the end node # allow reversed edges, no self loops, excluded the end node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [2] protected_nodes = [2]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1477,7 +1477,7 @@ class TestGisIdentify: ...@@ -1477,7 +1477,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1507,11 +1507,11 @@ class TestGisIdentify: ...@@ -1507,11 +1507,11 @@ class TestGisIdentify:
# no reversed edges, no self loops, no excluded nodes # no reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1523,11 +1523,11 @@ class TestGisIdentify: ...@@ -1523,11 +1523,11 @@ class TestGisIdentify:
# no reversed edges, allow self loops, no excluded nodes # no reversed edges, allow self loops, no excluded nodes
ignore_self_loops = True ignore_self_loops = True
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1539,11 +1539,11 @@ class TestGisIdentify: ...@@ -1539,11 +1539,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the middle node # do not allow reversed edges, no self loops, excluded the middle node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [1] protected_nodes = [1]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1555,11 +1555,11 @@ class TestGisIdentify: ...@@ -1555,11 +1555,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the start node # do not allow reversed edges, no self loops, excluded the start node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [0] protected_nodes = [0]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1571,11 +1571,11 @@ class TestGisIdentify: ...@@ -1571,11 +1571,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the end node # do not allow reversed edges, no self loops, excluded the end node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [2] protected_nodes = [2]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1593,11 +1593,11 @@ class TestGisIdentify: ...@@ -1593,11 +1593,11 @@ class TestGisIdentify:
# allow reversed edges, allow self loops, no excluded nodes # allow reversed edges, allow self loops, no excluded nodes
ignore_self_loops = True ignore_self_loops = True
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1608,7 +1608,7 @@ class TestGisIdentify: ...@@ -1608,7 +1608,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1618,11 +1618,11 @@ class TestGisIdentify: ...@@ -1618,11 +1618,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, no excluded nodes # allow reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1633,7 +1633,7 @@ class TestGisIdentify: ...@@ -1633,7 +1633,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1643,11 +1643,11 @@ class TestGisIdentify: ...@@ -1643,11 +1643,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the middle node # allow reversed edges, no self loops, excluded the middle node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [1] protected_nodes = [1]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1659,11 +1659,11 @@ class TestGisIdentify: ...@@ -1659,11 +1659,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the start node # allow reversed edges, no self loops, excluded the start node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [0] protected_nodes = [0]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1674,7 +1674,7 @@ class TestGisIdentify: ...@@ -1674,7 +1674,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1684,11 +1684,11 @@ class TestGisIdentify: ...@@ -1684,11 +1684,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the end node # allow reversed edges, no self loops, excluded the end node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [2] protected_nodes = [2]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1699,7 +1699,7 @@ class TestGisIdentify: ...@@ -1699,7 +1699,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1729,11 +1729,11 @@ class TestGisIdentify: ...@@ -1729,11 +1729,11 @@ class TestGisIdentify:
# no reversed edges, no self loops, no excluded nodes # no reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1745,11 +1745,11 @@ class TestGisIdentify: ...@@ -1745,11 +1745,11 @@ class TestGisIdentify:
# no reversed edges, allow self loops, no excluded nodes # no reversed edges, allow self loops, no excluded nodes
ignore_self_loops = True ignore_self_loops = True
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1761,11 +1761,11 @@ class TestGisIdentify: ...@@ -1761,11 +1761,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the middle node # do not allow reversed edges, no self loops, excluded the middle node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [1] protected_nodes = [1]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1777,11 +1777,11 @@ class TestGisIdentify: ...@@ -1777,11 +1777,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the start node # do not allow reversed edges, no self loops, excluded the start node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [0] protected_nodes = [0]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1793,11 +1793,11 @@ class TestGisIdentify: ...@@ -1793,11 +1793,11 @@ class TestGisIdentify:
# do not allow reversed edges, no self loops, excluded the end node # do not allow reversed edges, no self loops, excluded the end node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [2] protected_nodes = [2]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1815,11 +1815,11 @@ class TestGisIdentify: ...@@ -1815,11 +1815,11 @@ class TestGisIdentify:
# allow reversed edges, allow self loops, no excluded nodes # allow reversed edges, allow self loops, no excluded nodes
ignore_self_loops = True ignore_self_loops = True
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1830,7 +1830,7 @@ class TestGisIdentify: ...@@ -1830,7 +1830,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1840,11 +1840,11 @@ class TestGisIdentify: ...@@ -1840,11 +1840,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, no excluded nodes # allow reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1855,7 +1855,7 @@ class TestGisIdentify: ...@@ -1855,7 +1855,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1865,11 +1865,11 @@ class TestGisIdentify: ...@@ -1865,11 +1865,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the middle node # allow reversed edges, no self loops, excluded the middle node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [1] protected_nodes = [1]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1881,11 +1881,11 @@ class TestGisIdentify: ...@@ -1881,11 +1881,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the start node # allow reversed edges, no self loops, excluded the start node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [0] protected_nodes = [0]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1896,7 +1896,7 @@ class TestGisIdentify: ...@@ -1896,7 +1896,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1906,11 +1906,11 @@ class TestGisIdentify: ...@@ -1906,11 +1906,11 @@ class TestGisIdentify:
# allow reversed edges, no self loops, excluded the end node # allow reversed edges, no self loops, excluded the end node
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [2] protected_nodes = [2]
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1921,7 +1921,7 @@ class TestGisIdentify: ...@@ -1921,7 +1921,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1951,11 +1951,11 @@ class TestGisIdentify: ...@@ -1951,11 +1951,11 @@ class TestGisIdentify:
# no reversed edges, no self loops, no excluded nodes # no reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1966,7 +1966,7 @@ class TestGisIdentify: ...@@ -1966,7 +1966,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1982,11 +1982,11 @@ class TestGisIdentify: ...@@ -1982,11 +1982,11 @@ class TestGisIdentify:
# no reversed edges, no self loops, no excluded nodes # no reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -1997,7 +1997,7 @@ class TestGisIdentify: ...@@ -1997,7 +1997,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -2007,11 +2007,11 @@ class TestGisIdentify: ...@@ -2007,11 +2007,11 @@ class TestGisIdentify:
# no reversed edges, no self loops, no excluded nodes # no reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
include_both_directions=True, include_both_directions=True,
...@@ -2023,7 +2023,7 @@ class TestGisIdentify: ...@@ -2023,7 +2023,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -2053,11 +2053,11 @@ class TestGisIdentify: ...@@ -2053,11 +2053,11 @@ class TestGisIdentify:
# no reversed edges, no self loops, no excluded nodes # no reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -2068,7 +2068,7 @@ class TestGisIdentify: ...@@ -2068,7 +2068,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -2084,11 +2084,11 @@ class TestGisIdentify: ...@@ -2084,11 +2084,11 @@ class TestGisIdentify:
# no reversed edges, no self loops, no excluded nodes # no reversed edges, no self loops, no excluded nodes
ignore_self_loops = False ignore_self_loops = False
excluded_nodes = [] protected_nodes = []
straight_paths = gis_iden.find_simplifiable_paths( straight_paths = gis_iden.find_simplifiable_paths(
network, network,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
...@@ -2104,7 +2104,7 @@ class TestGisIdentify: ...@@ -2104,7 +2104,7 @@ class TestGisIdentify:
self.straight_path_validator( self.straight_path_validator(
network, network,
straight_path, straight_path,
excluded_nodes, protected_nodes,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
) )
......
...@@ -160,7 +160,7 @@ class TestGisModify: ...@@ -160,7 +160,7 @@ class TestGisModify:
# find paths # find paths
paths = gis_iden.find_simplifiable_paths( paths = gis_iden.find_simplifiable_paths(
_net, _net,
excluded_nodes=[], protected_nodes=[],
ignore_self_loops=ignore_self_loops, ignore_self_loops=ignore_self_loops,
consider_reversed_edges=consider_reversed_edges, consider_reversed_edges=consider_reversed_edges,
) )
...@@ -882,7 +882,7 @@ class TestGisModify: ...@@ -882,7 +882,7 @@ class TestGisModify:
) )
initial_number_edges = network.number_of_edges() initial_number_edges = network.number_of_edges()
true_edges_removed = [(0, 1, 1), (1, 2, 1), (2, 0, 1)] true_edges_removed = [(0, 1, 1), (1, 2, 1), (2, 0, 1)]
edges_removed = gis_mod.remove_longer_parallel_edges(network) edges_removed = gis_mod.remove_longer_parallel_edges(network, ignore_edge_directions=False)
assert len(edges_removed) == len(true_edges_removed) assert len(edges_removed) == len(true_edges_removed)
for edge_key in edges_removed: for edge_key in edges_removed:
assert edge_key in true_edges_removed assert edge_key in true_edges_removed
...@@ -903,7 +903,7 @@ class TestGisModify: ...@@ -903,7 +903,7 @@ class TestGisModify:
) )
initial_number_edges = network.number_of_edges() initial_number_edges = network.number_of_edges()
true_edges_removed = [(0, 1, 1), (0, 1, 2), (0, 1, 3)] true_edges_removed = [(0, 1, 1), (0, 1, 2), (0, 1, 3)]
edges_removed = gis_mod.remove_longer_parallel_edges(network) edges_removed = gis_mod.remove_longer_parallel_edges(network, ignore_edge_directions=False)
assert len(edges_removed) == len(true_edges_removed) assert len(edges_removed) == len(true_edges_removed)
for edge_key in edges_removed: for edge_key in edges_removed:
assert edge_key in true_edges_removed assert edge_key in true_edges_removed
...@@ -928,7 +928,7 @@ class TestGisModify: ...@@ -928,7 +928,7 @@ class TestGisModify:
) )
initial_number_edges = network.number_of_edges() initial_number_edges = network.number_of_edges()
true_edges_removed = [(0, 1, 1), (1, 2, 1), (2, 0, 1)] true_edges_removed = [(0, 1, 1), (1, 2, 1), (2, 0, 1)]
edges_removed = gis_mod.remove_longer_parallel_edges(network) edges_removed = gis_mod.remove_longer_parallel_edges(network, ignore_edge_directions=False)
assert len(edges_removed) == len(true_edges_removed) assert len(edges_removed) == len(true_edges_removed)
for edge_key in edges_removed: for edge_key in edges_removed:
assert edge_key in true_edges_removed assert edge_key in true_edges_removed
...@@ -961,7 +961,44 @@ class TestGisModify: ...@@ -961,7 +961,44 @@ class TestGisModify:
(2, 1, 0), (2, 1, 0),
(0, 2, 0), (0, 2, 0),
] ]
edges_removed = gis_mod.remove_longer_parallel_edges(network, True) edges_removed = gis_mod.remove_longer_parallel_edges(network, ignore_edge_directions=True)
assert len(edges_removed) == len(true_edges_removed)
for edge_key in edges_removed:
assert edge_key in true_edges_removed
assert network.number_of_edges() == initial_number_edges - len(edges_removed)
# example using protected edges
network = nx.MultiDiGraph()
network.add_edges_from(
[
(0, 1, 0, {"length": 3}),
(1, 2, 0, {"length": 4}),
(2, 0, 0, {"length": 5}),
# additional edges
(0, 1, 1, {"length": 4}),
(1, 2, 1, {"length": 5}),
(2, 0, 1, {"length": 6}),
# oppposite edges
(1, 0, 0, {"length": 7}),
(2, 1, 0, {"length": 8}),
(0, 2, 0, {"length": 9}),
]
)
initial_number_edges = network.number_of_edges()
true_edges_removed = [
(0, 1, 1),
(1, 2, 1),
#(2, 0, 1), # protected
(1, 0, 0),
(2, 1, 0),
(0, 2, 0),
]
edges_removed = gis_mod.remove_longer_parallel_edges(
network,
ignore_edge_directions=True,
protected_edges=[(0, 1, 0), (2, 0, 1)]
)
assert len(edges_removed) == len(true_edges_removed) assert len(edges_removed) == len(true_edges_removed)
for edge_key in edges_removed: for edge_key in edges_removed:
assert edge_key in true_edges_removed assert edge_key in true_edges_removed
...@@ -993,7 +1030,7 @@ class TestGisModify: ...@@ -993,7 +1030,7 @@ class TestGisModify:
("b", "a", 0), ("b", "a", 0),
(0, "b", 0), (0, "b", 0),
] ]
edges_removed = gis_mod.remove_longer_parallel_edges(network, True) edges_removed = gis_mod.remove_longer_parallel_edges(network, ignore_edge_directions=True)
assert len(edges_removed) == len(true_edges_removed) assert len(edges_removed) == len(true_edges_removed)
for edge_key in edges_removed: for edge_key in edges_removed:
assert edge_key in true_edges_removed assert edge_key in true_edges_removed
...@@ -1115,7 +1152,7 @@ class TestGisModify: ...@@ -1115,7 +1152,7 @@ class TestGisModify:
) )
nodes_removed = gis_mod.remove_dead_ends( nodes_removed = gis_mod.remove_dead_ends(
network, keepers=[4, 8], max_iterations=2 network, protected_nodes=[4, 8], max_iterations=2
) )
true_nodes_removed = [3, 6, 7] true_nodes_removed = [3, 6, 7]
...@@ -1170,16 +1207,34 @@ class TestGisModify: ...@@ -1170,16 +1207,34 @@ class TestGisModify:
custom_filter='["highway"~"residential|tertiary|unclassified|service"]', custom_filter='["highway"~"residential|tertiary|unclassified|service"]',
truncate_by_edge=True, truncate_by_edge=True,
) )
# copy the network
_net = network.copy() _net = network.copy()
# identify all the dead end nodes
dead_end_nodes = tuple(
node_key
for node_key in _net.nodes()
if len(tuple(gis_iden.neighbours(network, node_key))) == 1
)
share_keeper_dead_end_nodes = 0.25
keeper_dead_end_nodes = list(dead_end_nodes[0:round(len(dead_end_nodes)*share_keeper_dead_end_nodes)])
max_iterations = 5 max_iterations = 5
nodes_removed = gis_mod.remove_dead_ends( nodes_removed = gis_mod.remove_dead_ends(
_net, keepers=[], max_iterations=max_iterations _net, protected_nodes=keeper_dead_end_nodes, max_iterations=max_iterations
) )
# the nodes removed cannot include keeper nodes
for node_key in nodes_removed:
assert node_key not in keeper_dead_end_nodes
# TODO: perform checks for node_key in _net.nodes():
if node_key in keeper_dead_end_nodes:
# dead end node that was not meant to be removed
continue
# any other node cannot be a dead end node
assert node_key not in dead_end_nodes
# ensure that they have at least two neighbours
assert len(tuple(gis_iden.neighbours(_net, node_key))) >= 2
# ************************************************************************* # *************************************************************************
# ************************************************************************* # *************************************************************************
......
...@@ -12,6 +12,7 @@ from pandas import concat, MultiIndex, Series ...@@ -12,6 +12,7 @@ from pandas import concat, MultiIndex, Series
import networkx as nx import networkx as nx
import osmnx as ox import osmnx as ox
from shapely.geometry import Point, LineString from shapely.geometry import Point, LineString
from shapely import intersects
# local, internal # local, internal
...@@ -2115,7 +2116,493 @@ class TestGisUtils: ...@@ -2115,7 +2116,493 @@ class TestGisUtils:
# ************************************************************************* # *************************************************************************
# ************************************************************************* # *************************************************************************
def test_simplifying_graph(self): def test_simplify_network_manual(self):
# seed number
seed_number = random.randint(0, int(1e5))
random.seed(seed_number)
# define the network graph
network = nx.MultiDiGraph()
network.add_edges_from([
(1,2,0,{
_osm.KEY_OSMNX_OSMID: 1,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(1,2,0,{
_osm.KEY_OSMNX_OSMID: 2,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(2,3,0,{
_osm.KEY_OSMNX_OSMID: 3,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(3,3,0,{
_osm.KEY_OSMNX_OSMID: 4,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(3,4,0,{
_osm.KEY_OSMNX_OSMID: 5,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(2,5,0,{
_osm.KEY_OSMNX_OSMID: 6,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(5,6,0,{
_osm.KEY_OSMNX_OSMID: 7,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(6,7,0,{
_osm.KEY_OSMNX_OSMID: 8,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(5,8,0,{
_osm.KEY_OSMNX_OSMID: 1,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(8,9,0,{
_osm.KEY_OSMNX_OSMID: 9,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(9,10,0,{
_osm.KEY_OSMNX_OSMID: 10,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(10,12,0,{
_osm.KEY_OSMNX_OSMID: 11,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(12,11,0,{
_osm.KEY_OSMNX_OSMID: 12,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(8,11,0,{
_osm.KEY_OSMNX_OSMID: 13,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(8,13,0,{
_osm.KEY_OSMNX_OSMID: 14,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(13,14,0,{
_osm.KEY_OSMNX_OSMID: 15,
_osm.KEY_OSMNX_LENGTH: 3,
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(14,14,0,{
_osm.KEY_OSMNX_OSMID: 16,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(14,15,0,{
_osm.KEY_OSMNX_OSMID: 17,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(13,16,0,{
_osm.KEY_OSMNX_OSMID: 18,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(16,17,0,{
_osm.KEY_OSMNX_OSMID: 19,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(17,18,0,{
_osm.KEY_OSMNX_OSMID: 20,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(16,19,0,{
_osm.KEY_OSMNX_OSMID: 21,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(19,20,0,{
_osm.KEY_OSMNX_OSMID: 22,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(20,22,0,{
_osm.KEY_OSMNX_OSMID: 23,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(19,21,0,{
_osm.KEY_OSMNX_OSMID: 24,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(21,22,0,{
_osm.KEY_OSMNX_OSMID: 25,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(21,19,0,{
_osm.KEY_OSMNX_OSMID: 26,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(21,19,1,{
_osm.KEY_OSMNX_OSMID: 27,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(19,22,0,{
_osm.KEY_OSMNX_OSMID: 28,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(19,23,0,{
_osm.KEY_OSMNX_OSMID: 29,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(23,27,0,{
_osm.KEY_OSMNX_OSMID: 30,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(27,24,0,{
_osm.KEY_OSMNX_OSMID: 31,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(27,25,0,{
_osm.KEY_OSMNX_OSMID: 32,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(27,26,0,{
_osm.KEY_OSMNX_OSMID: 33,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(23,28,0,{
_osm.KEY_OSMNX_OSMID: 34,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(28,29,0,{
_osm.KEY_OSMNX_OSMID: 35,
_osm.KEY_OSMNX_LENGTH: 0.1,
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(29,32,0,{
_osm.KEY_OSMNX_OSMID: 36,
_osm.KEY_OSMNX_LENGTH: 0.1+0.1,
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(28,30,0,{
_osm.KEY_OSMNX_OSMID: 37,
_osm.KEY_OSMNX_LENGTH: 0.1,
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(30,32,0,{
_osm.KEY_OSMNX_OSMID: 38,
_osm.KEY_OSMNX_LENGTH: 0.1+0.2,
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(32,31,0,{
_osm.KEY_OSMNX_OSMID: 39,
_osm.KEY_OSMNX_LENGTH: 0.1,
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(31,28,0,{
_osm.KEY_OSMNX_OSMID: 40,
_osm.KEY_OSMNX_LENGTH: 0.1+0.3,
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
# branch for protected edge (33,34)
(23,33,0,{
_osm.KEY_OSMNX_OSMID: 41,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(33,34,0,{
_osm.KEY_OSMNX_OSMID: 42,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(34,35,0,{
_osm.KEY_OSMNX_OSMID: 43,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
# branch for protected edge (36,37)
(23,36,0,{
_osm.KEY_OSMNX_OSMID: 44,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(36,37,0,{
_osm.KEY_OSMNX_OSMID: 45,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
(37,38,0,{
_osm.KEY_OSMNX_OSMID: 46,
_osm.KEY_OSMNX_LENGTH: random.random(),
_osm.KEY_OSMNX_REVERSED: False,
_osm.KEY_OSMNX_ONEWAY: False,
},
),
])
# add node data
for i, node_key in enumerate(network.nodes()):
network.nodes[node_key][_osm.KEY_OSMNX_X] = i+random.random()
network.nodes[node_key][_osm.KEY_OSMNX_Y] = i+1+random.random()
# define the keepers
protected_nodes = [1, 2, 5, 8, 13, 16, 19, 4, 18, 22, 23, 24, 25, 26, 32, 35]
# identify the original nodes
node_keys = tuple(network.nodes())
# try simplifying it
gis_utils.simplify_network(
network,
protected_nodes=protected_nodes,
protected_edges=[(33,34,0),(36,37,0)]
)
# protected nodes must still exist
for node_key in protected_nodes:
assert network.has_node(node_key)
# there cannot be any self loop on the network
assert len(tuple(gis_iden.find_self_loops(network))) == 0
# there cannot be any simplifiable path
assert len(gis_iden.find_simplifiable_paths(network, protected_nodes)) == 0
# there cannot be any parallel arcs
for edge_key in network.edges(keys=True):
assert len(tuple(gis_iden.get_edges_between_two_nodes(network, *edge_key[0:2]))) == 1
# there cannot be dead ends
for node_key in node_keys:
# nodes that no longer exist cannot be checked
if not network.has_node(node_key):
continue
# some nodes can be dead ends, if they are protected
if node_key in protected_nodes:
continue
# all other nodes cannot be dead ends
assert len(tuple(gis_iden.neighbours(network, node_key))) >= 1
# *********************************************************************
# *********************************************************************
# final configuration
# there should be an edge between 2 and 4
assert network.has_edge(2, 4) or network.has_edge(4, 2)
# node 3 should not exist
assert not network.has_node(3)
# nodes 6 and 7 should not exist
assert not network.has_node(6) and not network.has_node(7)
# nodes 9, 10, 11, and 12 should not exist either
assert (
not network.has_node(9) and
not network.has_node(10) and
not network.has_node(11) and
not network.has_node(12)
)
# nodes 14 and 15 should not exist
assert not network.has_node(14) and not network.has_node(15)
# there should be an edge between 16 and 18
assert network.has_edge(16, 18) or network.has_edge(18, 16)
# node 17 should not exist
assert not network.has_node(17)
# there should be an edge between 19 and 22
assert network.has_edge(19, 22) or network.has_edge(22, 19)
# node 20 should not exist
assert not network.has_node(20)
# node 21 should not exist
assert not network.has_node(21)
# nodes 27, 33, 34 and 35 should exist
assert network.has_node(27)
assert network.has_node(33)
assert network.has_node(34)
assert network.has_node(35)
# there should be an edge between 33 and 34
assert network.has_edge(33, 34) or network.has_edge(34, 33)
# there should be an edge between 34 and 35
assert network.has_edge(34, 35) or network.has_edge(35, 34)
# nodes 28, 29, 30, and 31 should not exist
assert not network.has_node(28)
assert not network.has_node(29)
assert not network.has_node(30)
assert not network.has_node(31)
# there should be an edge between 23 and 32
assert network.has_edge(23, 32) or network.has_edge(32, 23)
# nodes 36 and 37 should exist, node 38 should not
assert network.has_node(36)
assert network.has_node(37)
assert not network.has_node(38)
# the edge (36,37) should exist
assert network.has_edge(36, 37) or network.has_edge(37, 36)
# *************************************************************************
# *************************************************************************
def test_simplify_network_osmnx(self):
# get a network # get a network
network = ox.graph_from_point( network = ox.graph_from_point(
(55.71654, 9.11728), (55.71654, 9.11728),
...@@ -2124,23 +2611,76 @@ class TestGisUtils: ...@@ -2124,23 +2611,76 @@ class TestGisUtils:
truncate_by_edge=True, truncate_by_edge=True,
) )
# protect some nodes # protect some nodes
number_nodes_protected = 4
node_keys = tuple(network.nodes()) node_keys = tuple(network.nodes())
share_nodes_protected = 0.25
number_nodes_protected = round(len(node_keys)*share_nodes_protected)
protected_nodes = [ protected_nodes = [
node_keys[random.randint(0, len(node_keys) - 1)] node_keys[random.randint(0, len(node_keys) - 1)]
for i in range(number_nodes_protected) for i in range(number_nodes_protected)
] ]
# try simplifying it # try simplifying it
gis_utils.simplify_network(network, protected_nodes) gis_utils.simplify_network(network, protected_nodes=protected_nodes)
# TODO: verify the changes # protected nodes must still exist
# confirm that the protected nodes still exist and have the same attr. for node_key in protected_nodes:
# for node_key in protected_nodes: assert network.has_node(node_key)
# assert network.has_node(node_key) # there cannot be any self loop on the network
# TODO: check if [335762579, 335762585, 1785975921, 360252989, 335762632, 335762579] is a path assert len(tuple(gis_iden.find_self_loops(network))) == 0
# there cannot be any simplifiable path
assert len(gis_iden.find_simplifiable_paths(network, protected_nodes)) == 0
# there cannot be any parallel arcs
for edge_key in network.edges(keys=True):
assert len(tuple(gis_iden.get_edges_between_two_nodes(network, *edge_key[0:2]))) == 1
# there cannot be dead ends
for node_key in node_keys:
# nodes that no longer exist cannot be checked
if not network.has_node(node_key):
continue
# some nodes can be dead ends, if they are protected
if node_key in protected_nodes:
continue
# all other nodes cannot be dead ends
assert len(tuple(gis_iden.neighbours(network, node_key))) >= 1
# ************************************************************************* # *************************************************************************
# ************************************************************************* # *************************************************************************
def test_create_edge_geometry(self):
G = nx.MultiDiGraph()
edge_key = (0, 1)
G.add_node(0, x=0, y=0)
G.add_node(1, x=1, y=1)
k1 = G.add_edge(0, 1, length=2**0.5)
first_geo = gis_utils.create_edge_geometry(G, edge_key)
edge_key = (2, 3)
G.add_node(2, x=0, y=1)
G.add_node(3, x=1, y=0)
k2 = G.add_edge(2, 3, length=2**0.5)
second_geo = gis_utils.create_edge_geometry(G, edge_key)
assert intersects(first_geo, second_geo)
# test finding overlapping edges
ol_edges = gis_utils.find_overlapping_edges(G)
assert len(ol_edges) == 1
assert ((0,1,k1),(2,3,k2)) in ol_edges
# no overlapping edges if there is only one node
ol_edges = gis_utils.find_overlapping_edges(G, excluded_edges=[(0,1,k1)])
assert len(ol_edges) == 0
# add fifth node
G.add_node(4, x=0.5, y=1)
k3 = G.add_edge(3, 4, length=(0.5**2+1**2)**0.5)
ol_edges = gis_utils.find_overlapping_edges(G)
assert len(ol_edges) == 2
assert ((0,1,k1),(2,3,k2)) in ol_edges
assert ((0,1,k1),(3,4,k3)) in ol_edges
# fewer overlapping edges
ol_edges = gis_utils.find_overlapping_edges(G, excluded_edges=[(2,3,k2)])
assert len(ol_edges) == 1
assert ((0,1,k1),(3,4,k3)) in ol_edges
# *************************************************************************
# *************************************************************************
# ***************************************************************************** # *****************************************************************************
# ***************************************************************************** # *****************************************************************************