Skip to content

Commit

Permalink
Specify None function outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobson committed Feb 5, 2024
1 parent d7af934 commit 1ab4002
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
6 changes: 3 additions & 3 deletions swmmanywhere/geospatial_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
def get_utm_epsg(x: float,
y: float,
crs: str | int | pyproj.CRS = 'EPSG:4326',
datum_name: str = "WGS 84"):
datum_name: str = "WGS 84") -> str:
"""Get the UTM CRS code for a given coordinate.
Note, this function is taken from GeoPandas and modified to use
Expand Down Expand Up @@ -154,7 +154,7 @@ def interpolate_points_on_raster(x: list[float],

def reproject_raster(target_crs: str,
fid: Path,
new_fid: Optional[Path] = None):
new_fid: Optional[Path] = None) -> None:
"""Reproject a raster to a new CRS.
Args:
Expand Down Expand Up @@ -302,7 +302,7 @@ def nearest_node_buffer(points1: dict[str, sgeom.Point],
def burn_shape_in_raster(geoms: list[sgeom.LineString],
depth: float,
raster_fid: Path,
new_raster_fid: Path):
new_raster_fid: Path) -> None:
"""Burn a depth into a raster along a list of shapely geometries.
Args:
Expand Down
27 changes: 14 additions & 13 deletions swmmanywhere/graph_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def load_graph(fid: Path) -> nx.Graph:
return G

def save_graph(G: nx.Graph,
fid: Path):
fid: Path) -> None:
"""Save a graph to a file.
Args:
Expand Down Expand Up @@ -93,7 +93,7 @@ def __call__(self,

def validate_requirements(self,
edge_attributes: set,
node_attributes: set):
node_attributes: set) -> None:
"""Validate that the graph has the required attributes."""
for attribute in self.required_edge_attributes:
assert attribute in edge_attributes, "{0} not in attributes".format(
Expand All @@ -106,7 +106,7 @@ def validate_requirements(self,

def add_graphfcn(self,
edge_attributes: set,
node_attributes: set):
node_attributes: set) -> tuple[set, set]:
"""Add the attributes that the graph function adds."""
self.validate_requirements(edge_attributes, node_attributes)
edge_attributes = edge_attributes.union(self.adds_edge_attributes)
Expand All @@ -131,7 +131,7 @@ def register_graphfcn(cls) -> Callable:
setattr(graphfcns, cls.__name__, cls())
return cls

def get_osmid_id(data):
def get_osmid_id(data: dict) -> Hashable:
"""Get the ID of an edge."""
id_ = data.get('osmid', data.get('id'))
if isinstance(id_, list):
Expand All @@ -149,7 +149,7 @@ def __init__(self):

def __call__(self,
G: nx.Graph,
**kwargs):
**kwargs) -> nx.Graph:
"""Assign an ID to each edge.
This function takes a graph and assigns an ID to each edge. The ID is
Expand Down Expand Up @@ -183,7 +183,7 @@ def __init__(self):
def __call__(self,
G: nx.Graph,
subcatchment_derivation: parameters.SubcatchmentDerivation,
**kwargs):
**kwargs) -> nx.Graph:
"""Format the lanes attribute of each edge and calculates width.
Args:
Expand Down Expand Up @@ -212,7 +212,7 @@ def __init__(self):
"""Initialize the class."""
super().__init__()
self.required_edge_attributes = ['id']
def __call__(self, G: nx.Graph, **kwargs):
def __call__(self, G: nx.Graph, **kwargs) -> nx.Graph:
"""Create a 'double directed graph'.
This function duplicates a graph and adds reverse edges to the new graph.
Expand Down Expand Up @@ -251,7 +251,7 @@ def __init__(self):
def __call__(self,
G: nx.Graph,
subcatchment_derivation: parameters.SubcatchmentDerivation,
**kwargs):
**kwargs) -> nx.Graph:
"""Split long edges into shorter edges.
This function splits long edges into shorter edges. The edges are split
Expand Down Expand Up @@ -385,7 +385,7 @@ def __init__(self):
def __call__(self, G: nx.Graph,
subcatchment_derivation: parameters.SubcatchmentDerivation,
addresses: parameters.Addresses,
**kwargs):
**kwargs) -> nx.Graph:
"""Calculate the contributing area for each edge.
This function calculates the contributing area for each edge. The
Expand Down Expand Up @@ -799,7 +799,7 @@ def design_pipe(ds_elevation: float,
edge_length: float,
pipe_design: parameters.HydraulicDesign,
Q: float
):
) -> nx.Graph:
"""Design a pipe.
This function designs a pipe by iterating over a range of diameters and
Expand Down Expand Up @@ -897,12 +897,13 @@ def process_successors(G: nx.Graph,
chamber_floor: dict[Hashable, float],
edge_diams: dict[tuple[Hashable,Hashable,int], float],
pipe_design: parameters.HydraulicDesign
):
) -> None:
"""Process the successors of a node.
This function processes the successors of a node. It designs a pipe to the
downstream node and sets the diameter and downstream invert level of the
pipe. It also sets the downstream invert level of the downstream node.
pipe. It also sets the downstream invert level of the downstream node. It
returns None but modifies the edge_diams and chamber_floor dictionaries.
Args:
G (nx.Graph): A graph
Expand Down Expand Up @@ -955,7 +956,7 @@ def __call__(self,
G: nx.Graph,
pipe_design: parameters.HydraulicDesign,
**kwargs
):
)->nx.Graph:
"""Pipe by pipe hydraulic design.
Starting from the most upstream node, design a pipe to the downstream node
Expand Down

0 comments on commit 1ab4002

Please sign in to comment.