@@ -456,50 +456,50 @@ def test_aggregate_to_src_idx(primal_graph, dual_graph):
456456 data_map = mock .mock_data_map (data_gdf , dedupe_key_col = dedupe_key_col )
457457 data_map .assign_data_to_network (network_structure_d , 400 , n_nearest_candidates = 6 )
458458 for netw_src_idx in network_structure_d .node_indices ():
459- # aggregate to src...
460- reachable_entries = data_map .aggregate_to_src_idx (
461- netw_src_idx , network_structure_d , int (max_seconds ), config .SPEED_M_S , angular = True
462- )
463- # compare to manual checks on distances:
464- # get the network distances
465- _nodes , tree_map = network_structure_d .dijkstra_tree_simplest (
466- netw_src_idx , int (max_seconds ), config .SPEED_M_S
467- )
468- # check that reachable entries and respective distances are correct
469- # should match against the network structure plus data_map.node_data_map distances
470- manual_reachable = {}
471- manual_not_reachable = {}
472- for node_idx , node_visit in enumerate (tree_map ): # type: ignore
473- if np .isfinite (node_visit .agg_seconds ):
474- if node_idx not in data_map .node_data_map :
475- continue
476- for assigned_data_idx , assigned_data_dist in data_map .node_data_map [node_idx ]:
477- dist = node_visit .agg_seconds * config .SPEED_M_S + assigned_data_dist
478- if dist <= max_dist :
479- manual_reachable [assigned_data_idx ] = dist
480- else :
481- manual_not_reachable [assigned_data_idx ] = dist
482- # all reachable entries should be in manual reachable and distances should be the same
483- for reachable_key , reachable_dist in reachable_entries .items ():
484- assert reachable_key in manual_reachable
485- assert reachable_dist - manual_reachable [reachable_key ] < config .ATOL
486- # manual reachable shouldn't contain keys not in reachable entries
487- # allow 1m tolerance for floating point errors
488- # handle shadowed dupe id nodes in deduplication case
489- shadowed_dupes = ["int:45" , "int:46" , "int:47" , "int:48" ]
490- for reachable_key in manual_reachable :
491- if deduplicate is True and reachable_key in shadowed_dupes :
492- # if shadowed by closest dedupe node, then it should not be reachable
493- # but if within max dist, then "int:49" should be reachable
494- assert "int:49" in manual_reachable
495- assert "int:49" in reachable_entries
496- assert reachable_key not in reachable_entries
459+ # aggregate to src...
460+ reachable_entries = data_map .aggregate_to_src_idx (
461+ netw_src_idx , network_structure_d , int (max_seconds ), config .SPEED_M_S , angular = True
462+ )
463+ # compare to manual checks on distances:
464+ # get the network distances
465+ _nodes , tree_map = network_structure_d .dijkstra_tree_simplest (
466+ netw_src_idx , int (max_seconds ), config .SPEED_M_S
467+ )
468+ # check that reachable entries and respective distances are correct
469+ # should match against the network structure plus data_map.node_data_map distances
470+ manual_reachable = {}
471+ manual_not_reachable = {}
472+ for node_idx , node_visit in enumerate (tree_map ): # type: ignore
473+ if np .isfinite (node_visit .agg_seconds ):
474+ if node_idx not in data_map .node_data_map :
497475 continue
498- try :
499- assert reachable_key in reachable_entries
500- except AssertionError :
501- # If the key is not found, assert the distance condition
502- assert max_dist - manual_reachable [reachable_key ] < 1
476+ for assigned_data_idx , assigned_data_dist in data_map .node_data_map [node_idx ]:
477+ dist = node_visit .agg_seconds * config .SPEED_M_S + assigned_data_dist
478+ if dist <= max_dist :
479+ manual_reachable [assigned_data_idx ] = dist
480+ else :
481+ manual_not_reachable [assigned_data_idx ] = dist
482+ # all reachable entries should be in manual reachable and distances should be the same
483+ for reachable_key , reachable_dist in reachable_entries .items ():
484+ assert reachable_key in manual_reachable
485+ assert reachable_dist - manual_reachable [reachable_key ] < config .ATOL
486+ # manual reachable shouldn't contain keys not in reachable entries
487+ # allow 1m tolerance for floating point errors
488+ # handle shadowed dupe id nodes in deduplication case
489+ shadowed_dupes = ["int:45" , "int:46" , "int:47" , "int:48" ]
490+ for reachable_key in manual_reachable :
491+ if deduplicate is True and reachable_key in shadowed_dupes :
492+ # if shadowed by closest dedupe node, then it should not be reachable
493+ # but if within max dist, then "int:49" should be reachable
494+ assert "int:49" in manual_reachable
495+ assert "int:49" in reachable_entries
496+ assert reachable_key not in reachable_entries
497+ continue
498+ try :
499+ assert reachable_key in reachable_entries
500+ except AssertionError :
501+ # If the key is not found, assert the distance condition
502+ assert max_dist - manual_reachable [reachable_key ] < 1
503503
504504
505505def test_accessibility (primal_graph , dual_graph ):
0 commit comments