Skip to content

Commit

Permalink
Update docs/naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobson committed May 10, 2024
1 parent 123e5b9 commit f9459fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 6 additions & 2 deletions swmmanywhere/graph_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ def __call__(self,
**kwargs) -> nx.Graph:
"""Format the lanes attribute of each edge and calculates width.
Only the `drive` network is assumed to contribute to impervious area and
so others `network_types` have lanes set to 0. If no `network_type` is
present, the edge is assumed to be of type `drive`.
Args:
G (nx.Graph): A graph
subcatchment_derivation (parameters.SubcatchmentDerivation): A
Expand Down Expand Up @@ -485,15 +489,15 @@ def __call__(self,
)

@register_graphfcn
class merge_nodes(BaseGraphFunction):
class merge_street_nodes(BaseGraphFunction):
"""merge_nodes class."""
def __call__(self,
G: nx.Graph,
subcatchment_derivation: parameters.SubcatchmentDerivation,
**kwargs) -> nx.Graph:
"""Merge nodes that are close together.
This function merges nodes that are within a certain distance of each
Merges `street` nodes that are within a certain distance of each
other. The distance is specified in the `node_merge_distance` attribute
of the `subcatchment_derivation` parameter. The merged nodes are given
the same coordinates, and the graph is relabeled with nx.relabel_nodes.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_data/demo_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ graphfcn_list:
- remove_parallel_edges # Remove parallel edges retaining the shorter one
- to_undirected # Convert graph to undirected to facilitate cleanup
- split_long_edges # Set a maximum edge length
- merge_nodes # Merge nodes that are too close together
- assign_id # Remove duplicates arising from merge_nodes
- merge_street_nodes # Merge street nodes that are too close together
- assign_id # Remove duplicates arising from merge_street_nodes
- clip_to_catchments # Clip graph to catchment subbasins
- calculate_contributing_area # Calculate runoff coefficient
- set_elevation # Set node elevation from DEM
Expand Down
6 changes: 3 additions & 3 deletions tests/test_graph_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,12 @@ def almost_equal(a, b, tol=1e-6):
"""Check if two numbers are almost equal."""
return abs(a-b) < tol

def test_merge_nodes():
"""Test the merge_nodes function."""
def test_merge_street_nodes():
"""Test the merge_street_nodes function."""
G, _ = load_street_network()
subcatchment_derivation = parameters.SubcatchmentDerivation(
node_merge_distance = 20)
G_ = gu.merge_nodes(G, subcatchment_derivation)
G_ = gu.merge_street_nodes(G, subcatchment_derivation)
assert not set([107736,266325461,2623975694,32925453]).intersection(G_.nodes)
assert almost_equal(G_.nodes[25510321]['x'], 700445.0112082)

Expand Down

0 comments on commit f9459fb

Please sign in to comment.