diff --git a/docs/generate_docs.py b/docs/generate_docs.py index 0c4babb1..66103cdb 100644 --- a/docs/generate_docs.py +++ b/docs/generate_docs.py @@ -1,6 +1,7 @@ from __future__ import annotations import importlib +import inspect from pathlib import Path import docstring_parser @@ -96,7 +97,7 @@ def strip_markdown(text: str) -> str: return cleaned_text -def process_docstring(doc_str: str) -> str: +def custom_process_docstring(doc_str: str) -> str: """Process a docstring.""" doc_str_frag: str = "" parsed_doc_str = docstring_parser.parse(doc_str) @@ -163,9 +164,65 @@ def process_docstring(doc_str: str) -> str: return doc_str_frag +def custom_format_signature(sig: inspect.Signature, colon: bool = True) -> str: + """pdoc currently returns expanded annotations - problematic for npt.Arraylike etc.""" + # First get a list with all params as strings. + params: list[str] = doc._PrettySignature._params(sig) # type: ignore + return_annot = doc._PrettySignature._return_annotation_str(sig) # type: ignore + parsed_return_annot: list[str] = [] + if return_annot not in ["", "None", None]: + ra = return_annot.lstrip("tuple[") + ra = ra.rstrip("]") + rs = ra.split(",") + for r in rs: + r = r.strip() + if "." in r: + r = r.split(".")[-1] + if r.lower() not in ["any", "nonetype"]: + parsed_return_annot.append(r) + # build tags + if len(params) <= 1 and len(parsed_return_annot) <= 1: + sig_fragment: tags.div = tags.div(cls="signature") + else: + sig_fragment: tags.div = tags.div(cls="signature multiline") + with sig_fragment: + tags.span("(", cls="pt") + # nest sig params for CSS alignment + for param in params: + param_fragment = tags.div(cls="param") + if ":" in param: + param_text, annot = param.split(":") + if "any" in annot.strip().lower(): + annot = None + elif annot.strip().lower().startswith("union"): + annot = None + else: + param_text = param + annot = None + with param_fragment: + tags.span(param_text, cls="pn") + if annot is not None: + with param_fragment: + tags.span(":", cls="pc") + tags.span(annot, cls="pa") + sig_fragment += param_fragment + if not parsed_return_annot: + with sig_fragment: + tags.span(")", cls="pt") + else: + with sig_fragment: + tags.span(")->[", cls="pt") + for parsed_return in parsed_return_annot: + tags.span(parsed_return, cls="pr") + tags.span("]", cls="pt") + + return sig_fragment.render() + + if __name__ == "__main__": # Add custom function - render.env.filters["process_docstring"] = process_docstring # type: ignore + render.env.filters["custom_process_docstring"] = custom_process_docstring # type: ignore + render.env.filters["custom_format_signature"] = custom_format_signature # type: ignore here = Path(__file__).parent module_file_maps = [ diff --git a/docs/pdoc_templates/module.html.jinja2 b/docs/pdoc_templates/module.html.jinja2 index 2a65faf4..ad45f208 100644 --- a/docs/pdoc_templates/module.html.jinja2 +++ b/docs/pdoc_templates/module.html.jinja2 @@ -1,9 +1,11 @@ {# DON'T INDENT -> CAUSES ISSUES FOR MARKDOWN OUTPUT +PRESERVE WHITE SPACE AROUND MARKDOWN BLOCKS FOR PARSER #} {% extends "frame.html.jinja2" %} {% block content %} +
{% block module_info %} {% if module.namespace %} @@ -20,6 +22,7 @@ DON'T INDENT -> CAUSES ISSUES FOR MARKDOWN OUTPUT {% endfor %} {% endblock %} +
{% endblock content %} {# End of content, beginning of helper macros. @@ -34,7 +37,6 @@ See https://pdoc.dev/docs/pdoc/render_helpers.html#DefaultMacroExtension for an {{ submodule(doc) }} {% else %} {{ variable(doc) }} -{{ docstring(doc) }} {% endif %} {% enddefaultmacro %} @@ -107,29 +109,30 @@ See https://pdoc.dev/docs/pdoc/render_helpers.html#DefaultMacroExtension for an
{% if fn.name == "__init__" %} {{ ".".join(fn.qualname.split(".")[:-1]) }} -{{- fn.signature_without_self | format_signature(colon=False) | linkify }} +{{- fn.signature_without_self | custom_format_signature | safe }} {% else %} {{ fn.name }} -{{- fn.signature | format_signature(colon=True) | linkify }} +{{- fn.signature | custom_format_signature | safe }} {% endif %}
{{ docstring(fn) }} {% enddefaultmacro %} -{% defaultmacro variable(var) -%} -{{ var.name }}{{ annotation(var) }}{{ default_value(var) }} -{% enddefaultmacro %} - {% defaultmacro submodule(mod) -%} {{ mod.taken_from | link }} {{ docstring(mod) }} {% enddefaultmacro %} +{% defaultmacro variable(var) -%} +{{ var.name }}{{ annotation(var) }}{{ default_value(var) }} +{{ docstring(doc) }} +{% enddefaultmacro %} + {% defaultmacro docstring(var) %} {% if var %} {% if var.docstring %} -{{ var.docstring | process_docstring | safe }} +{{ var.docstring | custom_process_docstring | safe }} {% endif %} {% endif %} {% enddefaultmacro %} diff --git a/docs/src/layouts/PageLayout.astro b/docs/src/layouts/PageLayout.astro index 509ff573..4f1c92ad 100644 --- a/docs/src/layouts/PageLayout.astro +++ b/docs/src/layouts/PageLayout.astro @@ -43,7 +43,7 @@ const navPaths = [ -
+
diff --git a/docs/src/pages/intro.md b/docs/src/pages/intro.md index 448ad394..26387f10 100644 --- a/docs/src/pages/intro.md +++ b/docs/src/pages/intro.md @@ -119,11 +119,15 @@ from cityseer.metrics import networks nodes_gdf, edges_gdf, network_structure = io.network_structure_from_nx(G_decomp, crs=3395) # the underlying method allows the computation of various centralities simultaneously, e.g. nodes_gdf = networks.segment_centrality( - network_structure=network_structure, # the network structure for which to compute the measures - nodes_gdf=nodes_gdf, # the nodes GeoDataFrame, to which the results will be written - distances=[200, 400, 800, 1600], # the distance thresholds for which to compute centralities + # the network structure for which to compute the measures + network_structure=network_structure, + # the nodes GeoDataFrame, to which the results will be written + nodes_gdf=nodes_gdf, + # the distance thresholds for which to compute centralities + distances=[200, 400, 800, 1600], ) -nodes_gdf.head() # the results are now in the GeoDataFrame +# the results are now in the GeoDataFrame +nodes_gdf.head() ``` ```python @@ -167,18 +171,26 @@ data_gdf.head() # example easy-wrapper method for computing mixed-uses # this is a distance weighted form of hill diversity nodes_gdf, data_gdf = layers.compute_mixed_uses( - data_gdf, # the source data - landuse_column_label="categorical_landuses", # column in the dataframe which contains the landuse labels - nodes_gdf=nodes_gdf, # nodes GeoDataFrame - the results are written here - network_structure=network_structure, # measures will be computed relative to pedestrian distances over the network - distances=[200, 400, 800, 1600], # distance thresholds for which you want to compute the measures + # the source data + data_gdf, + # column in the dataframe which contains the landuse labels + landuse_column_label="categorical_landuses", + # nodes GeoDataFrame - the results are written here + nodes_gdf=nodes_gdf, + # measures will be computed relative to pedestrian distances over the network + network_structure=network_structure, + # distance thresholds for which you want to compute the measures + distances=[200, 400, 800, 1600], ) -print(nodes_gdf.columns) # the GeoDataFrame will contain the results of the calculations -print(nodes_gdf["cc_metric_q0_800_hill"]) # which can be retrieved as needed +# the GeoDataFrame will contain the results of the calculations +print(nodes_gdf.columns) +# which can be retrieved as needed +print(nodes_gdf["cc_metric_q0_800_hill"]) ``` ```python -# for curiosity's sake - plot the assignments to see which edges the data points were assigned to +# for curiosity's sake: +# plot the assignments to see which edges the data points were assigned to plot.plot_assignment(network_structure, G_decomp, data_gdf, dpi=200, figsize=(4, 4)) ``` @@ -210,15 +222,22 @@ _800m distance-weighted mixed-uses._ ```python # compute landuse accessibilities for land-use types a, b, c nodes_gdf, data_gdf = layers.compute_accessibilities( - data_gdf, # the source data - landuse_column_label="categorical_landuses", # column in the dataframe which contains the landuse labels - accessibility_keys=["a", "b", "c"], # the landuse categories for which to compute accessibilities - nodes_gdf=nodes_gdf, # nodes GeoDataFrame - the results are written here - network_structure=network_structure, # measures will be computed relative to pedestrian distances over the network - distances=[200, 400, 800, 1600], # distance thresholds for which you want to compute the measures + # the source data + data_gdf, + # column in the dataframe which contains the landuse labels + landuse_column_label="categorical_landuses", + # the landuse categories for which to compute accessibilities + accessibility_keys=["a", "b", "c"], + # nodes GeoDataFrame - the results are written here + nodes_gdf=nodes_gdf, + # measures will be computed relative to pedestrian distances over the network + network_structure=network_structure, + # distance thresholds for which you want to compute the measures + distances=[200, 400, 800, 1600], ) -# accessibilities are computed in both weighted and unweighted forms, e.g. for "a" and "b" landuse codes -print(nodes_gdf[["cc_metric_a_800_weighted", "cc_metric_b_1600_non_weighted"]]) # and can be retrieved as needed +# accessibilities are computed in both weighted and unweighted forms +# e.g. for "a" and "b" landuse codes in weighted and non weighted, respectively +print(nodes_gdf[["cc_metric_a_800_weighted", "cc_metric_b_1600_non_weighted"]]) ``` Aggregations can likewise be computed for numerical data. Let's generate some mock numerical data: @@ -228,13 +247,19 @@ numerical_data_gdf = mock.mock_numerical_data(G_decomp, num_arrs=3) numerical_data_gdf.head() # compute stats for column mock_numerical_1 nodes_gdf, numerical_data_gdf = layers.compute_stats( - numerical_data_gdf, # the source data - stats_column_label="mock_numerical_1", # numerical column to compute stats for - nodes_gdf=nodes_gdf, # nodes GeoDataFrame - the results are written here - network_structure=network_structure, # measures will be computed relative to pedestrian distances over the network - distances=[800, 1600], # distance thresholds for which you want to compute the measures + # the source data + numerical_data_gdf, + # numerical column to compute stats for + stats_column_label="mock_numerical_1", + # nodes GeoDataFrame - the results are written here + nodes_gdf=nodes_gdf, + # measures will be computed relative to pedestrian distances over the network + network_structure=network_structure, + # distance thresholds for which you want to compute the measures + distances=[800, 1600], ) -# statistical aggregations are calculated for each requested column, and in the following forms: +# statistical aggregations are calculated for each requested column, +# and in the following forms: # max, min, sum, sum_weighted, mean, mean_weighted, variance, variance_weighted print(nodes_gdf["cc_metric_max_800"]) print(nodes_gdf["cc_metric_mean_wt_800"]) diff --git a/docs/src/pages/metrics/layers.md b/docs/src/pages/metrics/layers.md index 9a3b64bb..ccb62a6b 100644 --- a/docs/src/pages/metrics/layers.md +++ b/docs/src/pages/metrics/layers.md @@ -1,6 +1,7 @@ --- layout: ../../layouts/PageLayout.astro --- +
# layers @@ -11,7 +12,33 @@ layout: ../../layouts/PageLayout.astro
-assign_gdf_to_network( data_gdf: geopandas.geodataframe.GeoDataFrame, network_structure: NetworkStructure, max_netw_assign_dist: int | float, data_id_col: str | None = None) -> tuple[DataMap, geopandas.geodataframe.GeoDataFrame]: +assign_gdf_to_network
+ ( +
+ data_gdf + : + geopandas.geodataframe.GeoDataFrame +
+
+ network_structure + : + NetworkStructure +
+
+ max_netw_assign_dist + : + int | float +
+
+ data_id_col + : + str | None = None +
+ )->[ + DataMap + GeoDataFrame + ] +
@@ -80,7 +107,7 @@ layout: ../../layouts/PageLayout.astro ### Notes -:::warning +:::note The `max_assign_dist` parameter should not be set overly low. The `max_assign_dist` parameter sets a crow-flies distance limit on how far the algorithm will search in its attempts to encircle the data point. If the `max_assign_dist` is too small, then the algorithm is potentially hampered from finding a starting node; or, if a @@ -110,7 +137,78 @@ representation of variations of metrics along street-fronts.
-compute_accessibilities( data_gdf: geopandas.geodataframe.GeoDataFrame, landuse_column_label: str, accessibility_keys: list[str], nodes_gdf: geopandas.geodataframe.GeoDataFrame, network_structure: NetworkStructure, max_netw_assign_dist: int = 400, distances: list[int] | None = None, betas: list[float] | None = None, data_id_col: str | None = None, angular: bool = False, spatial_tolerance: int = 0, min_threshold_wt: float | None = None, jitter_scale: float = 0.0) -> tuple[geopandas.geodataframe.GeoDataFrame, geopandas.geodataframe.GeoDataFrame]: +compute_accessibilities
+ ( +
+ data_gdf + : + geopandas.geodataframe.GeoDataFrame +
+
+ landuse_column_label + : + str +
+
+ accessibility_keys + : + list[str] +
+
+ nodes_gdf + : + geopandas.geodataframe.GeoDataFrame +
+
+ network_structure + : + NetworkStructure +
+
+ max_netw_assign_dist + : + int = 400 +
+
+ distances + : + list[int] | None = None +
+
+ betas + : + list[float] | None = None +
+
+ data_id_col + : + str | None = None +
+
+ angular + : + bool = False +
+
+ spatial_tolerance + : + int = 0 +
+
+ min_threshold_wt + : + float | None = None +
+
+ jitter_scale + : + float = 0.0 +
+ )->[ + GeoDataFrame + GeoDataFrame + ] +
@@ -305,7 +403,93 @@ print(nodes_gdf["cc_metric_c_400_non_weighted"])
-compute_mixed_uses( data_gdf: geopandas.geodataframe.GeoDataFrame, landuse_column_label: str, nodes_gdf: geopandas.geodataframe.GeoDataFrame, network_structure: NetworkStructure, max_netw_assign_dist: int = 400, compute_hill: bool | None = True, compute_hill_weighted: bool | None = True, compute_shannon: bool | None = False, compute_gini: bool | None = False, distances: list[int] | None = None, betas: list[float] | None = None, data_id_col: str | None = None, angular: bool = False, spatial_tolerance: int = 0, min_threshold_wt: float | None = None, jitter_scale: float = 0.0) -> tuple[geopandas.geodataframe.GeoDataFrame, geopandas.geodataframe.GeoDataFrame]: +compute_mixed_uses
+ ( +
+ data_gdf + : + geopandas.geodataframe.GeoDataFrame +
+
+ landuse_column_label + : + str +
+
+ nodes_gdf + : + geopandas.geodataframe.GeoDataFrame +
+
+ network_structure + : + NetworkStructure +
+
+ max_netw_assign_dist + : + int = 400 +
+
+ compute_hill + : + bool | None = True +
+
+ compute_hill_weighted + : + bool | None = True +
+
+ compute_shannon + : + bool | None = False +
+
+ compute_gini + : + bool | None = False +
+
+ distances + : + list[int] | None = None +
+
+ betas + : + list[float] | None = None +
+
+ data_id_col + : + str | None = None +
+
+ angular + : + bool = False +
+
+ spatial_tolerance + : + int = 0 +
+
+ min_threshold_wt + : + float | None = None +
+
+ jitter_scale + : + float = 0.0 +
+ )->[ + GeoDataFrame + GeoDataFrame + ] +
@@ -550,7 +734,73 @@ been applied.
-compute_stats( data_gdf: geopandas.geodataframe.GeoDataFrame, stats_column_label: str | list[str] | tuple[str], nodes_gdf: geopandas.geodataframe.GeoDataFrame, network_structure: NetworkStructure, max_netw_assign_dist: int = 400, distances: list[int] | None = None, betas: list[float] | None = None, data_id_col: str | None = None, angular: bool = False, spatial_tolerance: int = 0, min_threshold_wt: float | None = None, jitter_scale: float = 0.0) -> tuple[geopandas.geodataframe.GeoDataFrame, geopandas.geodataframe.GeoDataFrame]: +compute_stats
+ ( +
+ data_gdf + : + geopandas.geodataframe.GeoDataFrame +
+
+ stats_column_label + : + str | list[str] | tuple[str] +
+
+ nodes_gdf + : + geopandas.geodataframe.GeoDataFrame +
+
+ network_structure + : + NetworkStructure +
+
+ max_netw_assign_dist + : + int = 400 +
+
+ distances + : + list[int] | None = None +
+
+ betas + : + list[float] | None = None +
+
+ data_id_col + : + str | None = None +
+
+ angular + : + bool = False +
+
+ spatial_tolerance + : + int = 0 +
+
+ min_threshold_wt + : + float | None = None +
+
+ jitter_scale + : + float = 0.0 +
+ )->[ + GeoDataFrame + GeoDataFrame + ] +
@@ -740,3 +990,4 @@ computed distances: +
diff --git a/docs/src/pages/metrics/networks.md b/docs/src/pages/metrics/networks.md index cb3f7ea8..1b9ad36b 100644 --- a/docs/src/pages/metrics/networks.md +++ b/docs/src/pages/metrics/networks.md @@ -1,6 +1,7 @@ --- layout: ../../layouts/PageLayout.astro --- +
# networks @@ -57,7 +58,52 @@ may therefore be preferable when working at small thresholds on decomposed netwo
-node_centrality_shortest( network_structure: NetworkStructure, nodes_gdf: geopandas.geodataframe.GeoDataFrame, distances: list[int] | None = None, betas: list[float] | None = None, compute_closeness: bool | None = True, compute_betweenness: bool | None = True, min_threshold_wt: float = 0.01831563888873418, jitter_scale: float = 0.0) -> geopandas.geodataframe.GeoDataFrame: +node_centrality_shortest
+ ( +
+ network_structure + : + NetworkStructure +
+
+ nodes_gdf + : + geopandas.geodataframe.GeoDataFrame +
+
+ distances + : + list[int] | None = None +
+
+ betas + : + list[float] | None = None +
+
+ compute_closeness + : + bool | None = True +
+
+ compute_betweenness + : + bool | None = True +
+
+ min_threshold_wt + : + float = 0.01831563888873418 +
+
+ jitter_scale + : + float = 0.0 +
+ )->[ + GeoDataFrame + ] +
@@ -183,7 +229,52 @@ network representations.
-node_centrality_simplest( network_structure: NetworkStructure, nodes_gdf: geopandas.geodataframe.GeoDataFrame, distances: list[int] | None = None, betas: list[float] | None = None, compute_closeness: bool | None = True, compute_betweenness: bool | None = True, min_threshold_wt: float = 0.01831563888873418, jitter_scale: float = 0.0) -> geopandas.geodataframe.GeoDataFrame: +node_centrality_simplest
+ ( +
+ network_structure + : + NetworkStructure +
+
+ nodes_gdf + : + geopandas.geodataframe.GeoDataFrame +
+
+ distances + : + list[int] | None = None +
+
+ betas + : + list[float] | None = None +
+
+ compute_closeness + : + bool | None = True +
+
+ compute_betweenness + : + bool | None = True +
+
+ min_threshold_wt + : + float = 0.01831563888873418 +
+
+ jitter_scale + : + float = 0.0 +
+ )->[ + GeoDataFrame + ] +
@@ -306,7 +397,52 @@ The following keys use the simplest-path (shortest-angular-path) heuristic, and
-segment_centrality( network_structure: NetworkStructure, nodes_gdf: geopandas.geodataframe.GeoDataFrame, distances: list[int] | None = None, betas: list[float] | None = None, compute_closeness: bool | None = True, compute_betweenness: bool | None = True, min_threshold_wt: float = 0.01831563888873418, jitter_scale: float = 0.0) -> geopandas.geodataframe.GeoDataFrame: +segment_centrality
+ ( +
+ network_structure + : + NetworkStructure +
+
+ nodes_gdf + : + geopandas.geodataframe.GeoDataFrame +
+
+ distances + : + list[int] | None = None +
+
+ betas + : + list[float] | None = None +
+
+ compute_closeness + : + bool | None = True +
+
+ compute_betweenness + : + bool | None = True +
+
+ min_threshold_wt + : + float = 0.01831563888873418 +
+
+ jitter_scale + : + float = 0.0 +
+ )->[ + GeoDataFrame + ] +
@@ -420,3 +556,4 @@ The following keys use the simplest-path (shortest-angular-path) heuristic, and +
diff --git a/docs/src/pages/metrics/observe.md b/docs/src/pages/metrics/observe.md index 0ed8b53d..58406e98 100644 --- a/docs/src/pages/metrics/observe.md +++ b/docs/src/pages/metrics/observe.md @@ -1,29 +1,49 @@ --- layout: ../../layouts/PageLayout.astro --- +
# observe -Observe module for computing observations derived from `networkX` graphs. These methods are generally sufficiently simple that further computational optimisation is not required. Network centrality methods (which do require further computational optimisation due to their complexity) are handled separately in the [`networks`](/metrics/networks) module. + + Observe module for computing observations derived from `networkX` graphs. These methods are generally sufficiently simple that further computational optimisation is not required. Network centrality methods (which do require further computational optimisation due to their complexity) are handled separately in the [`networks`](/metrics/networks) module. +
+ ## ContinuityEntry -State management for an individual street continuity entry. This corresponds to an individual street name, route name or number, or highway type. + + + State management for an individual street continuity entry. This corresponds to an individual street name, route name or number, or highway type. + +
## ContinuityEntry +
-ContinuityEntry(entry_name: str) +ContinuityEntry
+ ( +
+ entry_name + : + str +
+ ) +
-Instances a continuity entry. + + Instances a continuity entry.
+ +
## generate_key @@ -31,95 +51,224 @@ Instances a continuity entry.
@staticmethod
-generate_key(start_nd_key: str, end_nd_key: str, edge_idx: int): +generate_key
+ ( +
+ start_nd_key + : + str +
+
+ end_nd_key + : + str +
+
+ edge_idx + : + int +
+ )
+
+ -Generate a unique key given uncertainty of start and end node order. + Generate a unique key given uncertainty of start and end node order.
+ +
## add_edge +
-add_edge( self, length: float, start_nd_key: str, end_nd_key: str, edge_idx: int) -> None: +add_edge
+ ( +
+ self +
+
+ length + : + float +
+
+ start_nd_key + : + str +
+
+ end_nd_key + : + str +
+
+ edge_idx + : + int +
+ ) +
-Adds edge details to a continuity entry. + + Adds edge details to a continuity entry.
+
+
+ ## StreetContinuityReport -State management for a collection of street continuity metrics. Each key in the `entries` attribute corresponds to a `ContinuityEntry`. + + + State management for a collection of street continuity metrics. Each key in the `entries` attribute corresponds to a `ContinuityEntry`. + +
## StreetContinuityReport +
-StreetContinuityReport(method: str) +StreetContinuityReport
+ ( +
+ method + : + str +
+ ) +
-Instance a street continuity report. + + Instance a street continuity report.
+ +
## scaffold_entry +
-scaffold_entry(self, entry_name: str) -> None: +scaffold_entry
+ ( +
+ self +
+
+ entry_name + : + str +
+ )
+
+ -Adds a new continuity entry to the report's entries. + Adds a new continuity entry to the report's entries.
+ +
## report_by_count +
-report_by_count(self, n_items: int = 10) -> None: +report_by_count
+ ( +
+ self +
+
+ n_items + : + int = 10 +
+ ) +
-Print a report sorted by entry counts. + + Print a report sorted by entry counts.
+ +
## report_by_length +
-report_by_length(self, n_items: int = 10) -> None: +report_by_length
+ ( +
+ self +
+
+ n_items + : + int = 10 +
+ ) +
-Print a report sorted by entry lengths. + + Print a report sorted by entry lengths.
+
+
## street_continuity +
-street_continuity( nx_multigraph: networkx.classes.multigraph.MultiGraph, method: str | tuple[str, str]) -> tuple[networkx.classes.multigraph.MultiGraph, StreetContinuityReport]: +street_continuity
+ ( +
+ nx_multigraph + : + networkx.classes.multigraph.MultiGraph +
+
+ method + : + str | tuple[str, str] +
+ )->[ + MultiGraph + StreetContinuityReport + ] +
-Compute the street continuity for a given graph. This requires a graph with `names`, `routes`, or `highways` edge keys corresponding to the selected `method` parameter. These keys are available if importing an OSM network with [`osm_graph_from_poly`](/tools/io#osm-graph-from-poly) or if importing OS Open Roads data with [nx_from_open_roads](/tools/io#nx-from-open-roads). + Compute the street continuity for a given graph. This requires a graph with `names`, `routes`, or `highways` edge keys corresponding to the selected `method` parameter. These keys are available if importing an OSM network with [`osm_graph_from_poly`](/tools/io#osm-graph-from-poly) or if importing OS Open Roads data with [nx_from_open_roads](/tools/io#nx-from-open-roads). ### Parameters -
nx_multigraph
@@ -127,8 +276,7 @@ Compute the street continuity for a given graph. This requires a graph with `nam
-A `networkX` `MultiGraph` in a projected coordinate system, containing `x` and `y` node attributes, and `geom` edge attributes containing `LineString` geoms. Edges should contain "names", "routes", or "highways" keys corresponding to the specified `method` parameter.
- + A `networkX` `MultiGraph` in a projected coordinate system, containing `x` and `y` node attributes, and `geom` edge attributes containing `LineString` geoms. Edges should contain "names", "routes", or "highways" keys corresponding to the specified `method` parameter.
@@ -138,12 +286,10 @@ A `networkX` `MultiGraph` in a projected coordinate system, containing `x` and `
-The type of continuity metric to compute, where available options are "names", "routes", or "highways".
- + The type of continuity metric to compute, where available options are "names", "routes", or "highways".
### Returns -
@@ -151,8 +297,7 @@ The type of continuity metric to compute, where available options are "name
-A copy of the input `networkX` `MultiGraph` with new edge keys corresponding to the calculated route continuity metric. The metrics will be stored in 'length' and 'count' forms for the specified method, with keys formatted according to `f"{method}_cont_by_{form}"`. For example, when computing "names" continuity, the `names_cont_by_count` and `names_cont_by_length` keys will be added to the returned `networkX` `MultiGraph`.
- + A copy of the input `networkX` `MultiGraph` with new edge keys corresponding to the calculated route continuity metric. The metrics will be stored in 'length' and 'count' forms for the specified method, with keys formatted according to `f"{method}_cont_by_{form}"`. For example, when computing "names" continuity, the `names_cont_by_count` and `names_cont_by_length` keys will be added to the returned `networkX` `MultiGraph`.
@@ -162,24 +307,36 @@ A copy of the input `networkX` `MultiGraph` with new edge keys corresponding to
-An instance of [`StreetContinuityReport`](/metrics/observe#streetcontinuityreport) containing the computed state for the selected method.
- + An instance of [`StreetContinuityReport`](/metrics/observe#streetcontinuityreport) containing the computed state for the selected method. + +
## hybrid_street_continuity +
-hybrid_street_continuity( nx_multigraph: networkx.classes.multigraph.MultiGraph) -> tuple[networkx.classes.multigraph.MultiGraph, StreetContinuityReport]: +hybrid_street_continuity
+ ( +
+ nx_multigraph + : + networkx.classes.multigraph.MultiGraph +
+ )->[ + MultiGraph + StreetContinuityReport + ] +
-Compute the street continuity for a given graph using a hybridisation of routes and names continuity. Hybrid continuity merges route continuity and street continuity information where a route overlaps a street continuity. + Compute the street continuity for a given graph using a hybridisation of routes and names continuity. Hybrid continuity merges route continuity and street continuity information where a route overlaps a street continuity. ### Parameters -
nx_multigraph
@@ -187,12 +344,10 @@ Compute the street continuity for a given graph using a hybridisation of routes
-A `networkX` `MultiGraph` in a projected coordinate system, containing `x` and `y` node attributes, and `geom` edge attributes containing `LineString` geoms. Edges should contain "names", "routes", or "highways" keys corresponding to the specified `method` parameter.
- + A `networkX` `MultiGraph` in a projected coordinate system, containing `x` and `y` node attributes, and `geom` edge attributes containing `LineString` geoms. Edges should contain "names", "routes", or "highways" keys corresponding to the specified `method` parameter.
### Returns -
@@ -200,8 +355,7 @@ A `networkX` `MultiGraph` in a projected coordinate system, containing `x` and `
-A copy of the input `networkX` `MultiGraph` with new edge keys corresponding to the calculated route continuity metric. The metrics will be stored in 'hybrid_cont_by_length' and 'hybrid_cont_by_count' keys.
- + A copy of the input `networkX` `MultiGraph` with new edge keys corresponding to the calculated route continuity metric. The metrics will be stored in 'hybrid_cont_by_length' and 'hybrid_cont_by_count' keys.
@@ -211,8 +365,12 @@ A copy of the input `networkX` `MultiGraph` with new edge keys corresponding to
-An instance of [`StreetContinuityReport`](/metrics/observe#streetcontinuityreport) containing the computed state for the "hybrid" method.
- + An instance of [`StreetContinuityReport`](/metrics/observe#streetcontinuityreport) containing the computed state for the "hybrid" method. + + + + + diff --git a/docs/src/pages/tools/graphs.md b/docs/src/pages/tools/graphs.md index a7480f16..c2c5eab6 100644 --- a/docs/src/pages/tools/graphs.md +++ b/docs/src/pages/tools/graphs.md @@ -1,6 +1,7 @@ --- layout: ../../layouts/PageLayout.astro --- +
# graphs @@ -14,7 +15,18 @@ layout: ../../layouts/PageLayout.astro
-nx_simple_geoms(nx_multigraph: Any, simplify_dist: int = 5) -> Any: +nx_simple_geoms
+ ( +
+ nx_multigraph +
+
+ simplify_dist + : + int = 5 +
+ ) +
@@ -61,7 +73,13 @@ layout: ../../layouts/PageLayout.astro
-nx_remove_filler_nodes(nx_multigraph: Any) -> Any: +nx_remove_filler_nodes
+ ( +
+ nx_multigraph +
+ ) +
@@ -105,7 +123,28 @@ side-effects as a function of varied node intensities when computing network cen
-nx_remove_dangling_nodes( nx_multigraph: Any, despine: float | None = None, remove_disconnected: bool = True, cleanup_filler_nodes: bool = True) -> Any: +nx_remove_dangling_nodes
+ ( +
+ nx_multigraph +
+
+ despine + : + float | None = None +
+
+ remove_disconnected + : + bool = True +
+
+ cleanup_filler_nodes + : + bool = True +
+ ) +
@@ -172,7 +211,23 @@ side-effects as a function of varied node intensities when computing network cen
-nx_merge_parallel_edges( nx_multigraph: Any, merge_edges_by_midline: bool, contains_buffer_dist: int) -> Any: +nx_merge_parallel_edges
+ ( +
+ nx_multigraph +
+
+ merge_edges_by_midline + : + bool +
+
+ contains_buffer_dist + : + int +
+ ) +
@@ -233,7 +288,13 @@ side-effects as a function of varied node intensities when computing network cen
-nx_snap_endpoints(nx_multigraph: Any) -> Any: +nx_snap_endpoints
+ ( +
+ nx_multigraph +
+ ) +
@@ -270,7 +331,13 @@ side-effects as a function of varied node intensities when computing network cen
-nx_iron_edges(nx_multigraph: Any) -> Any: +nx_iron_edges
+ ( +
+ nx_multigraph +
+ ) +
@@ -307,7 +374,48 @@ side-effects as a function of varied node intensities when computing network cen
-nx_consolidate_nodes( nx_multigraph: Any, buffer_dist: float = 5, neighbour_policy: str | None = None, crawl: bool = False, centroid_by_straightness: bool = True, centroid_by_min_len_factor: float | None = None, merge_edges_by_midline: bool = True, contains_buffer_dist: int = 20) -> Any: +nx_consolidate_nodes
+ ( +
+ nx_multigraph +
+
+ buffer_dist + : + float = 5 +
+
+ neighbour_policy + : + str | None = None +
+
+ crawl + : + bool = False +
+
+ centroid_by_straightness + : + bool = True +
+
+ centroid_by_min_len_factor + : + float | None = None +
+
+ merge_edges_by_midline + : + bool = True +
+
+ contains_buffer_dist + : + int = 20 +
+ ) +
@@ -430,7 +538,28 @@ side-effects as a function of varied node intensities when computing network cen
-nx_split_opposing_geoms( nx_multigraph: Any, buffer_dist: float = 10, merge_edges_by_midline: bool = True, contains_buffer_dist: float = 20) -> Any: +nx_split_opposing_geoms
+ ( +
+ nx_multigraph +
+
+ buffer_dist + : + float = 10 +
+
+ merge_edges_by_midline + : + bool = True +
+
+ contains_buffer_dist + : + float = 20 +
+ ) +
@@ -501,7 +630,18 @@ side-effects as a function of varied node intensities when computing network cen
-nx_decompose(nx_multigraph: Any, decompose_max: float) -> Any: +nx_decompose
+ ( +
+ nx_multigraph +
+
+ decompose_max + : + float +
+ ) +
@@ -569,7 +709,13 @@ plot.plot_nx(G_decomposed)
-nx_to_dual(nx_multigraph: Any) -> Any: +nx_to_dual
+ ( +
+ nx_multigraph +
+ ) +
@@ -627,7 +773,18 @@ plot.plot_nx_primal_or_dual(G_simple,
-nx_weight_by_dissolved_edges(nx_multigraph: Any, dissolve_distance: int = 20) -> Any: +nx_weight_by_dissolved_edges
+ ( +
+ nx_multigraph +
+
+ dissolve_distance + : + int = 20 +
+ ) +
@@ -669,3 +826,4 @@ plot.plot_nx_primal_or_dual(G_simple, +
diff --git a/docs/src/pages/tools/io.md b/docs/src/pages/tools/io.md index 17f2694e..5478c13b 100644 --- a/docs/src/pages/tools/io.md +++ b/docs/src/pages/tools/io.md @@ -1,6 +1,7 @@ --- layout: ../../layouts/PageLayout.astro --- +
# io @@ -14,7 +15,23 @@ layout: ../../layouts/PageLayout.astro
-nx_epsg_conversion(nx_multigraph: Any, from_epsg_code: int, to_epsg_code: int) -> Any: +nx_epsg_conversion
+ ( +
+ nx_multigraph +
+
+ from_epsg_code + : + int +
+
+ to_epsg_code + : + int +
+ ) +
@@ -71,7 +88,18 @@ layout: ../../layouts/PageLayout.astro
-nx_wgs_to_utm(nx_multigraph: Any, force_zone_number: int | None = None) -> Any: +nx_wgs_to_utm
+ ( +
+ nx_multigraph +
+
+ force_zone_number + : + int | None = None +
+ ) +
@@ -118,7 +146,30 @@ layout: ../../layouts/PageLayout.astro
-buffered_point_poly( lng: float, lat: float, buffer: int) -> tuple[shapely.geometry.polygon.Polygon, shapely.geometry.polygon.Polygon, int, str]: +buffered_point_poly
+ ( +
+ lng + : + float +
+
+ lat + : + float +
+
+ buffer + : + int +
+ )->[ + Polygon + Polygon + int + str + ] +
@@ -205,7 +256,27 @@ layout: ../../layouts/PageLayout.astro
-fetch_osm_network( osm_request: str, timeout: int = 300, max_tries: int = 3) -> requests.models.Response | None: +fetch_osm_network
+ ( +
+ osm_request + : + str +
+
+ timeout + : + int = 300 +
+
+ max_tries + : + int = 3 +
+ )->[ + Response | None + ] +
@@ -267,7 +338,65 @@ builds a graph automatically.
-osm_graph_from_poly( poly_geom: shapely.geometry.polygon.Polygon, poly_epsg_code: int = 4326, to_epsg_code: int | None = None, buffer_dist: int = 15, custom_request: str | None = None, simplify: bool = True, remove_parallel: bool = True, iron_edges: bool = True, remove_disconnected: bool = True, timeout: int = 300, max_tries: int = 3) -> Any: +osm_graph_from_poly
+ ( +
+ poly_geom + : + shapely.geometry.polygon.Polygon +
+
+ poly_epsg_code + : + int = 4326 +
+
+ to_epsg_code + : + int | None = None +
+
+ buffer_dist + : + int = 15 +
+
+ custom_request + : + str | None = None +
+
+ simplify + : + bool = True +
+
+ remove_parallel + : + bool = True +
+
+ iron_edges + : + bool = True +
+
+ remove_disconnected + : + bool = True +
+
+ timeout + : + int = 300 +
+
+ max_tries + : + int = 3 +
+ ) +
@@ -427,7 +556,15 @@ out qt;
-nx_from_osm(osm_json: str) -> Any: +nx_from_osm
+ ( +
+ osm_json + : + str +
+ ) +
@@ -464,7 +601,28 @@ out qt;
-nx_from_osm_nx( nx_multidigraph: Any, node_attributes: list[str] | None = None, edge_attributes: list[str] | None = None, tolerance: float = 0.001) -> Any: +nx_from_osm_nx
+ ( +
+ nx_multidigraph +
+
+ node_attributes + : + list[str] | None = None +
+
+ edge_attributes + : + list[str] | None = None +
+
+ tolerance + : + float = 0.001 +
+ ) +
@@ -537,7 +695,22 @@ out qt;
-nx_from_open_roads( open_roads_path: str | pathlib.Path, target_bbox: Union[tuple[int, int, int, int], tuple[float, float, float, float], NoneType] = None) -> networkx.classes.multigraph.MultiGraph: +nx_from_open_roads
+ ( +
+ open_roads_path + : + str | pathlib.Path +
+
+ target_bbox + : + tuple[float] | None = None +
+ )->[ + MultiGraph + ] +
@@ -584,7 +757,22 @@ out qt;
-network_structure_from_nx( nx_multigraph: Any, crs: str | int) -> tuple[geopandas.geodataframe.GeoDataFrame, geopandas.geodataframe.GeoDataFrame, NetworkStructure]: +network_structure_from_nx
+ ( +
+ nx_multigraph +
+
+ crs + : + str | int +
+ )->[ + GeoDataFrame + GeoDataFrame + NetworkStructure + ] +
@@ -651,7 +839,20 @@ out qt;
-nx_from_geopandas( nodes_gdf: geopandas.geodataframe.GeoDataFrame, edges_gdf: geopandas.geodataframe.GeoDataFrame) -> Any: +nx_from_geopandas
+ ( +
+ nodes_gdf + : + geopandas.geodataframe.GeoDataFrame +
+
+ edges_gdf + : + geopandas.geodataframe.GeoDataFrame +
+ ) +
@@ -693,3 +894,4 @@ out qt; +
diff --git a/docs/src/pages/tools/mock.md b/docs/src/pages/tools/mock.md index 937e91a7..3293e17c 100644 --- a/docs/src/pages/tools/mock.md +++ b/docs/src/pages/tools/mock.md @@ -1,6 +1,7 @@ --- layout: ../../layouts/PageLayout.astro --- +
# mock @@ -14,7 +15,15 @@ layout: ../../layouts/PageLayout.astro
-mock_graph(wgs84_coords: bool = False) -> Any: +mock_graph
+ ( +
+ wgs84_coords + : + bool = False +
+ ) +
@@ -61,7 +70,18 @@ plot.plot_nx(nx_multigraph)
-get_graph_extents(nx_multigraph: Any) -> tuple[float, float, float, float]: +get_graph_extents
+ ( +
+ nx_multigraph +
+ )->[ + float + float + float + float + ] +
@@ -132,7 +152,25 @@ plot.plot_nx(nx_multigraph)
-mock_data_gdf( nx_multigraph: Any, length: int = 50, random_seed: int = 0) -> geopandas.geodataframe.GeoDataFrame: +mock_data_gdf
+ ( +
+ nx_multigraph +
+
+ length + : + int = 50 +
+
+ random_seed + : + int = 0 +
+ )->[ + GeoDataFrame + ] +
@@ -189,7 +227,30 @@ plot.plot_nx(nx_multigraph)
-mock_landuse_categorical_data( nx_multigraph: Any, length: int = 50, num_classes: int = 10, random_seed: int = 0) -> geopandas.geodataframe.GeoDataFrame: +mock_landuse_categorical_data
+ ( +
+ nx_multigraph +
+
+ length + : + int = 50 +
+
+ num_classes + : + int = 10 +
+
+ random_seed + : + int = 0 +
+ )->[ + GeoDataFrame + ] +
@@ -256,7 +317,45 @@ plot.plot_nx(nx_multigraph)
-mock_numerical_data( nx_multigraph: Any, length: int = 50, val_min: int = 0, val_max: int = 100000, num_arrs: int = 1, floating_pt: int = 3, random_seed: int = 0) -> geopandas.geodataframe.GeoDataFrame: +mock_numerical_data
+ ( +
+ nx_multigraph +
+
+ length + : + int = 50 +
+
+ val_min + : + int = 0 +
+
+ val_max + : + int = 100000 +
+
+ num_arrs + : + int = 1 +
+
+ floating_pt + : + int = 3 +
+
+ random_seed + : + int = 0 +
+ )->[ + GeoDataFrame + ] +
@@ -353,7 +452,18 @@ plot.plot_nx(nx_multigraph)
-mock_species_data( random_seed: int = 0) -> Generator[tuple[list[int], list[float]], NoneType, NoneType]: +mock_species_data
+ ( +
+ random_seed + : + int = 0 +
+ )->[ + Generator[tuple[list[int] + list[float]] + ] +
@@ -421,3 +531,4 @@ for counts, probs in mock.mock_species_data(): +
diff --git a/docs/src/pages/tools/plot.md b/docs/src/pages/tools/plot.md index 9d92a5f9..f1dcd09b 100644 --- a/docs/src/pages/tools/plot.md +++ b/docs/src/pages/tools/plot.md @@ -1,6 +1,7 @@ --- layout: ../../layouts/PageLayout.astro --- +
# plot @@ -25,7 +26,10 @@ layout: ../../layouts/PageLayout.astro
-ColourMap() +ColourMap
+ ( + ) +
@@ -40,7 +44,81 @@ layout: ../../layouts/PageLayout.astro
-plot_nx_primal_or_dual( primal_graph: typing.Any | None = None, dual_graph: typing.Any | None = None, path: str | None = None, labels: bool = False, primal_node_size: int = 30, primal_node_colour: Union[str, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]], NoneType] = None, primal_edge_colour: Union[str, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]], NoneType] = None, dual_node_size: int = 30, dual_node_colour: Union[str, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]], NoneType] = None, dual_edge_colour: Union[str, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]], NoneType] = None, primal_edge_width: int | float | None = None, dual_edge_width: int | float | None = None, plot_geoms: bool = True, x_lim: tuple[float, float] | None = None, y_lim: tuple[float, float] | None = None, ax: matplotlib.axes._axes.Axes | None = None, **kwargs: dict[str, typing.Any]): +plot_nx_primal_or_dual
+ ( +
+ primal_graph +
+
+ dual_graph +
+
+ path + : + str | None = None +
+
+ labels + : + bool = False +
+
+ primal_node_size + : + int = 30 +
+
+ primal_node_colour +
+
+ primal_edge_colour +
+
+ dual_node_size + : + int = 30 +
+
+ dual_node_colour +
+
+ dual_edge_colour +
+
+ primal_edge_width + : + int | float | None = None +
+
+ dual_edge_width + : + int | float | None = None +
+
+ plot_geoms + : + bool = True +
+
+ x_lim + : + tuple[float, float] | None = None +
+
+ y_lim + : + tuple[float, float] | None = None +
+
+ ax + : + matplotlib.axes._axes.Axes | None = None +
+
+ **kwargs +
+ ) +
@@ -241,7 +319,62 @@ plot.plot_nx_primal_or_dual(G_simple,
-plot_nx( nx_multigraph: Any, path: str | None = None, labels: bool = False, node_size: int = 20, node_colour: Union[str, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]], NoneType] = None, edge_colour: Union[str, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]], NoneType] = None, edge_width: int | float | None = None, plot_geoms: bool = False, x_lim: tuple[float, float] | None = None, y_lim: tuple[float, float] | None = None, ax: matplotlib.axes._axes.Axes | None = None, **kwargs: dict[str, typing.Any]): +plot_nx
+ ( +
+ nx_multigraph +
+
+ path + : + str | None = None +
+
+ labels + : + bool = False +
+
+ node_size + : + int = 20 +
+
+ node_colour +
+
+ edge_colour +
+
+ edge_width + : + int | float | None = None +
+
+ plot_geoms + : + bool = False +
+
+ x_lim + : + tuple[float, float] | None = None +
+
+ y_lim + : + tuple[float, float] | None = None +
+
+ ax + : + matplotlib.axes._axes.Axes | None = None +
+
+ **kwargs +
+ ) +
@@ -411,7 +544,42 @@ plot.plot_nx(G_after, node_colour=cols)
-plot_assignment( network_structure: NetworkStructure, nx_multigraph: Any, data_gdf: geopandas.geodataframe.GeoDataFrame, path: str | None = None, node_colour: Union[str, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]], NoneType] = None, node_labels: bool = False, data_labels: Union[str, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]], NoneType] = None, **kwargs: dict[str, typing.Any]): +plot_assignment
+ ( +
+ network_structure + : + NetworkStructure +
+
+ nx_multigraph +
+
+ data_gdf + : + geopandas.geodataframe.GeoDataFrame +
+
+ path + : + str | None = None +
+
+ node_colour +
+
+ node_labels + : + bool = False +
+
+ data_labels +
+
+ **kwargs +
+ ) +
@@ -513,7 +681,25 @@ This method is primarily intended for package testing and development.
-plot_network_structure( network_structure: NetworkStructure, data_gdf: geopandas.geodataframe.GeoDataFrame, poly: shapely.geometry.polygon.Polygon | None = None): +plot_network_structure
+ ( +
+ network_structure + : + NetworkStructure +
+
+ data_gdf + : + geopandas.geodataframe.GeoDataFrame +
+
+ poly + : + shapely.geometry.polygon.Polygon | None = None +
+ ) +
@@ -563,7 +749,64 @@ mainly to visually confirm the correct behaviour of particular algorithms during
-plot_scatter( ax: matplotlib.axes._axes.Axes, xs: Union[list[float], numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], ys: Union[list[float], numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], vals: Union[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], bbox_extents: tuple[int, int, int, int] | tuple[float, float, float, float], perc_range: tuple[float, float] = (0.01, 99.99), cmap_key: str = 'viridis', shape_exp: float = 1, s_min: float = 0.1, s_max: float = 1, rasterized: bool = True, face_colour: str = '#111') -> Any: +plot_scatter
+ ( +
+ ax + : + matplotlib.axes._axes.Axes +
+
+ xs +
+
+ ys +
+
+ vals +
+
+ bbox_extents + : + tuple[int, int, int, int] | tuple[float, float, float, float] +
+
+ perc_range + : + tuple[float, float] = (0.01, 99.99) +
+
+ cmap_key + : + str = 'viridis' +
+
+ shape_exp + : + float = 1 +
+
+ s_min + : + float = 0.1 +
+
+ s_max + : + float = 1 +
+
+ rasterized + : + bool = True +
+
+ face_colour + : + str = '#111' +
+ ) +
@@ -699,7 +942,85 @@ mainly to visually confirm the correct behaviour of particular algorithms during
-plot_nx_edges( ax: matplotlib.axes._axes.Axes, nx_multigraph: networkx.classes.multigraph.MultiGraph, edge_metrics_key: str, bbox_extents: tuple[int, int, int, int] | tuple[float, float, float, float], perc_range: tuple[float, float] = (0.01, 99.99), cmap_key: str = 'viridis', shape_exp: float = 1, lw_min: float = 0.1, lw_max: float = 1, edge_label_key: str | None = None, colour_by_categorical: bool = False, max_n_categorical: int = 10, rasterized: bool = True, face_colour: str = '#111', invert_plot_order: bool = False): +plot_nx_edges
+ ( +
+ ax + : + matplotlib.axes._axes.Axes +
+
+ nx_multigraph + : + networkx.classes.multigraph.MultiGraph +
+
+ edge_metrics_key + : + str +
+
+ bbox_extents + : + tuple[int, int, int, int] | tuple[float, float, float, float] +
+
+ perc_range + : + tuple[float, float] = (0.01, 99.99) +
+
+ cmap_key + : + str = 'viridis' +
+
+ shape_exp + : + float = 1 +
+
+ lw_min + : + float = 0.1 +
+
+ lw_max + : + float = 1 +
+
+ edge_label_key + : + str | None = None +
+
+ colour_by_categorical + : + bool = False +
+
+ max_n_categorical + : + int = 10 +
+
+ rasterized + : + bool = True +
+
+ face_colour + : + str = '#111' +
+
+ invert_plot_order + : + bool = False +
+ ) +
@@ -860,3 +1181,4 @@ mainly to visually confirm the correct behaviour of particular algorithms during +
diff --git a/docs/src/pages/tools/util.md b/docs/src/pages/tools/util.md index aa40033d..32de49f2 100644 --- a/docs/src/pages/tools/util.md +++ b/docs/src/pages/tools/util.md @@ -1,6 +1,7 @@ --- layout: ../../layouts/PageLayout.astro --- +
# util @@ -14,7 +15,18 @@ layout: ../../layouts/PageLayout.astro
-measure_bearing( xy_1: numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]], xy_2: numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]]) -> float: +measure_bearing
+ ( +
+ xy_1 +
+
+ xy_2 +
+ )->[ + float + ] +
@@ -29,7 +41,21 @@ layout: ../../layouts/PageLayout.astro
-measure_coords_angle( coords_1: numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]], coords_2: numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]], coords_3: numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]]) -> float: +measure_coords_angle
+ ( +
+ coords_1 +
+
+ coords_2 +
+
+ coords_3 +
+ )->[ + float + ] +
@@ -44,7 +70,17 @@ layout: ../../layouts/PageLayout.astro
-measure_cumulative_angle( linestring_coords: list[typing.Union[tuple[float, float], tuple[float, float, float]]]) -> float: +measure_cumulative_angle
+ ( +
+ linestring_coords + : + list[typing.Union[tuple[float, float], tuple[float, float, float]]] +
+ )->[ + float + ] +
@@ -59,7 +95,22 @@ layout: ../../layouts/PageLayout.astro
-substring(geom, start_dist, end_dist, normalized=False): +substring
+ ( +
+ geom +
+
+ start_dist +
+
+ end_dist +
+
+ normalized=False +
+ ) +
@@ -74,7 +125,22 @@ layout: ../../layouts/PageLayout.astro
-snap_linestring_startpoint( linestring_coords: Union[list[Union[tuple[float, float], tuple[float, float, float]]], numpy.ndarray[Any, numpy.dtype[numpy.float64]], shapely.coords.CoordinateSequence], x_y: Union[tuple[float, float], tuple[float, float, float]]) -> list[typing.Union[tuple[float, float], tuple[float, float, float]]]: +snap_linestring_startpoint
+ ( +
+ linestring_coords +
+
+ x_y +
+ )->[ + Union[tuple[float + float] + tuple[float + float + float + ] +
@@ -121,7 +187,22 @@ layout: ../../layouts/PageLayout.astro
-snap_linestring_endpoint( linestring_coords: Union[list[Union[tuple[float, float], tuple[float, float, float]]], numpy.ndarray[Any, numpy.dtype[numpy.float64]], shapely.coords.CoordinateSequence], x_y: Union[tuple[float, float], tuple[float, float, float]]) -> list[typing.Union[tuple[float, float], tuple[float, float, float]]]: +snap_linestring_endpoint
+ ( +
+ linestring_coords +
+
+ x_y +
+ )->[ + Union[tuple[float + float] + tuple[float + float + float + ] +
@@ -168,7 +249,32 @@ layout: ../../layouts/PageLayout.astro
-align_linestring_coords( linestring_coords: Union[list[Union[tuple[float, float], tuple[float, float, float]]], numpy.ndarray[Any, numpy.dtype[numpy.float64]], shapely.coords.CoordinateSequence], x_y: Union[tuple[float, float], tuple[float, float, float]], reverse: bool = False, tolerance: float = 0.5) -> list[typing.Union[tuple[float, float], tuple[float, float, float]]]: +align_linestring_coords
+ ( +
+ linestring_coords +
+
+ x_y +
+
+ reverse + : + bool = False +
+
+ tolerance + : + float = 0.5 +
+ )->[ + Union[tuple[float + float] + tuple[float + float + float + ] +
@@ -235,7 +341,41 @@ layout: ../../layouts/PageLayout.astro
-snap_linestring_endpoints( nx_multigraph: networkx.classes.multigraph.MultiGraph, start_nd_key: str, end_nd_key: str, linestring_coords: list[typing.Union[tuple[float, float], tuple[float, float, float]]], tolerance: float = 0.5) -> list[typing.Union[tuple[float, float], tuple[float, float, float]]]: +snap_linestring_endpoints
+ ( +
+ nx_multigraph + : + networkx.classes.multigraph.MultiGraph +
+
+ start_nd_key + : + str +
+
+ end_nd_key + : + str +
+
+ linestring_coords + : + list[typing.Union[tuple[float, float], tuple[float, float, float]]] +
+
+ tolerance + : + float = 0.5 +
+ )->[ + Union[tuple[float + float] + tuple[float + float + float + ] +
@@ -312,7 +452,30 @@ layout: ../../layouts/PageLayout.astro
-weld_linestring_coords( linestring_coords_a: Union[list[Union[tuple[float, float], tuple[float, float, float]]], numpy.ndarray[Any, numpy.dtype[numpy.float64]], shapely.coords.CoordinateSequence], linestring_coords_b: Union[list[Union[tuple[float, float], tuple[float, float, float]]], numpy.ndarray[Any, numpy.dtype[numpy.float64]], shapely.coords.CoordinateSequence], force_xy: Union[tuple[float, float], tuple[float, float, float], NoneType] = None, tolerance: float = 0.01) -> list[typing.Union[tuple[float, float], tuple[float, float, float]]]: +weld_linestring_coords
+ ( +
+ linestring_coords_a +
+
+ linestring_coords_b +
+
+ force_xy +
+
+ tolerance + : + float = 0.01 +
+ )->[ + Union[tuple[float + float] + tuple[float + float + float + ] +
@@ -338,7 +501,10 @@ layout: ../../layouts/PageLayout.astro
-EdgeInfo() +EdgeInfo
+ ( + ) +
@@ -351,25 +517,16 @@ layout: ../../layouts/PageLayout.astro names - - Returns a set of street names. - routes - - Returns a set of routes - e.g. route numbers. - highways - - Returns a set of highway types - e.g. footway. -
@@ -378,7 +535,16 @@ layout: ../../layouts/PageLayout.astro
-gather_edge_info(self, edge_data: dict[str, typing.Any]): +gather_edge_info
+ ( +
+ self +
+
+ edge_data +
+ ) +
@@ -394,7 +560,33 @@ layout: ../../layouts/PageLayout.astro
-set_edge_info( self, nx_multigraph: networkx.classes.multigraph.MultiGraph, start_node_key: str, end_node_key: str, edge_idx: int): +set_edge_info
+ ( +
+ self +
+
+ nx_multigraph + : + networkx.classes.multigraph.MultiGraph +
+
+ start_node_key + : + str +
+
+ end_node_key + : + str +
+
+ edge_idx + : + int +
+ ) +
@@ -412,7 +604,36 @@ layout: ../../layouts/PageLayout.astro
-add_node( nx_multigraph: Any, nodes_names: list[str], x: float, y: float, live: bool | None = None) -> tuple[str, bool]: +add_node
+ ( +
+ nx_multigraph +
+
+ nodes_names + : + list[str] +
+
+ x + : + float +
+
+ y + : + float +
+
+ live + : + bool | None = None +
+ )->[ + str + bool + ] +
@@ -427,7 +648,16 @@ layout: ../../layouts/PageLayout.astro
-create_nodes_strtree( nx_multigraph: Any) -> tuple[shapely.strtree.STRtree, list[dict[str, typing.Any]]]: +create_nodes_strtree
+ ( +
+ nx_multigraph +
+ )->[ + STRtree + list[dict[str + ] +
@@ -442,7 +672,16 @@ layout: ../../layouts/PageLayout.astro
-create_edges_strtree( nx_multigraph: Any) -> tuple[shapely.strtree.STRtree, list[dict[str, typing.Any]]]: +create_edges_strtree
+ ( +
+ nx_multigraph +
+ )->[ + STRtree + list[dict[str + ] +
@@ -457,7 +696,25 @@ layout: ../../layouts/PageLayout.astro
-blend_metrics( nodes_gdf: geopandas.geodataframe.GeoDataFrame, edges_gdf: geopandas.geodataframe.GeoDataFrame, method: str) -> Any: +blend_metrics
+ ( +
+ nodes_gdf + : + geopandas.geodataframe.GeoDataFrame +
+
+ edges_gdf + : + geopandas.geodataframe.GeoDataFrame +
+
+ method + : + str +
+ ) +
@@ -509,3 +766,4 @@ layout: ../../layouts/PageLayout.astro +
diff --git a/docs/src/styles/tailwind.css b/docs/src/styles/tailwind.css index 808b9608..aecf1d03 100644 --- a/docs/src/styles/tailwind.css +++ b/docs/src/styles/tailwind.css @@ -22,11 +22,11 @@ } h1 { - @apply pt-12 pb-4 font-mono text-3xl font-medium; + @apply pt-12 pb-4 text-3xl font-normal; } h2 { - @apply pl-2 pt-6 pb-2 font-mono text-2xl font-normal; + @apply pt-6 pb-2 text-2xl font-normal; } h3 { @@ -115,12 +115,12 @@ @media only screen and (width <= 1200px) { h1 { - @apply pt-8 pb-2 text-2xl font-light; + @apply pt-8 pb-2 text-2xl font-normal; } h2, h3 { - @apply pt-6 pb-1 font-medium; + @apply pt-6 pb-1 font-light; } h2 { diff --git a/docs/src/styles/yapper.css b/docs/src/styles/yapper.css index d5f59411..a6f1551b 100644 --- a/docs/src/styles/yapper.css +++ b/docs/src/styles/yapper.css @@ -1,18 +1,23 @@ -.md-content { - @apply m-3 py-3; +.module { + @apply m-3 py-3 text-sm font-normal; & p { - @apply px-1; + @apply px-1 leading-relaxed; } - & .title { - @apply pl-2 text-3xl font-medium; + @media only screen and (width <= 1200px) { + @apply leading-normal; + } + + & h1 { + @apply pl-2 text-4xl font-medium font-mono; } & .class { @apply my-8 border-l-3 border-t-1 border-mid-grey pl-2; - & .title { + & h2 { + @apply font-mono; } & .attr { @@ -23,28 +28,59 @@ } & .function { - @apply my-4 border-l border-mid-grey bg-dark-grey px-0.5; + @apply my-4 border-l border-mid-grey bg-dark-grey px-0.5 flex flex-col; + + & h2 { + @apply font-mono; + } & .decorator { - @apply text-sm font-medium p-1; + @apply text-sm font-medium font-mono p-1; } & .content { - @apply mb-2 text-sm flex items-start border-t-2 border-theme bg-darker-grey p-3 font-mono; + @apply flex mb-2 text-xs items-start border-t-2 border-theme bg-darker-grey p-3 font-mono font-light; } & .name { + @apply font-normal; } & .multiline { @apply flex-col; + + & .pr { + @apply pl-2; + } + + & .param { + @apply pl-2; + } } & .signature { - @apply flex; + @apply flex flex-wrap; & .param { - @apply px-0.5; + @apply font-light text-xs; + + & .pn { + } + + & .pc { + @apply text-xxs; + } + + & .pa { + @apply font-extralight text-xxs; + } + } + + & .pt { + } + + & .pr { + @apply font-extralight text-xxs; } } }