Skip to content

Commit

Permalink
Lint 00-mwe.py and utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
cbueth committed Apr 22, 2024
1 parent 876c154 commit cb3f1d3
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
7 changes: 4 additions & 3 deletions examples/00-mwe.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Minimum working example for superblockify."""

# While this script is running, figures will be generated on screen.
# While this script is running, figures will be generated on screen.
# Close the figure windows to proceed with the script execution.


Expand All @@ -12,10 +12,11 @@
name="Scheveningen_test",
city_name="Scheveningen",
search_str="Scheveningen, NL",
unit="time", # "time", "distance", any other edge attribute, or None to count edges
unit="time",
# "time", "distance", any other edge attribute, or None to count edges
)
# If you want to select a different city, find the corresponding search string
# (`search_str`) at https://nominatim.openstreetmap.org/.
# (`search_str`) at https://nominatim.openstreetmap.org/.
# The smaller the place, the quicker the partitioning.
# For large places sufficient memory is required.

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ suggestion-mode = true
[tool.pylint.basic]
# Regular expression matching correct module names. Overrides module-naming-
# style. Additionally to snake case allows for a prepended 'yyyymmdd-' string.
module-rgx = "(\\d{4}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])-)?(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$"
module-rgx = "(0*\\d+-)?(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$"

[tool.pylint.format]
# Maximum number of characters on a single line.
Expand Down
4 changes: 2 additions & 2 deletions superblockify/metrics/measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,8 @@ def add_relative_changes(components, attr_pairs):
:func:`superblockify.utils.percentual_increase`.
Write the relative percentual change of the specified edge attribute(s) to each
Superblock in the list of components. The relative change is the percentual change of
the first to the second attribute.
Superblock in the list of components.
The relative change is the percentual change of the first to the second attribute.
Works in-place and adds `change_{attr1}` to each Superblock.
If `attr1` has a value of 2 and `attr2` has a value of 1, the relative change is
-0.5, a 50% decrease. If `attr1` has a value of 4 and `attr2` has a value of 6,
Expand Down
4 changes: 2 additions & 2 deletions superblockify/partitioning/approaches/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def write_attribute(self, **kwargs):
def partition_graph(self, make_plots=False, **kwargs):
"""Group by boolean attribute and remove small components.
Construct sparsified graph from boolean attribute and Superblock subgraphs for the
components that fall apart.
Construct sparsified graph from boolean attribute and Superblock subgraphs
for the components that fall apart.
Parameters
----------
Expand Down
8 changes: 4 additions & 4 deletions superblockify/partitioning/approaches/steiner_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def write_attribute(
into which the residual graph decomposes.
Edges that are `oneway` can be excluded with `remove_oneway_edges`.
The idea is so this approach can produce Superblocks that are reachable from every
other Superblock, as Steiner trees are calculated on undirected graphs. But htis
highly depends on how the place was mapped. If arterial roads in two directions
are mapped as two separate ways, this is not the way out.
The idea is so this approach can produce Superblocks that are reachable from
every other Superblock, as Steiner trees are calculated on undirected graphs.
But this highly depends on how the place was mapped. If arterial roads in two
directions are mapped as two separate ways, this is not the way out.
Normally, the sampling probability is uniform, but if `low_betweenness_mode` is
set, the sampling probability is inversely proportional to the betweenness
Expand Down
11 changes: 7 additions & 4 deletions superblockify/partitioning/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ def save_to_gpkg(
The path to save the geodatapackage to. If None, it will be saved to the
partitioners folder at (part.results_dir, part.name + ".gpkg")
ltn_boundary : bool, optional
If True, the boundary of the Superblocks will be saved as a polygon into the `cell`
attribute of the Superblocks layer. For this, the tessellation needs to be calculated.
If True, the boundary of the Superblocks will be saved as a polygon into the
`cell` attribute of the Superblocks layer. For this, the tessellation needs
to be calculated.
Raises
------
Expand Down Expand Up @@ -98,12 +99,14 @@ def save_to_gpkg(
if partitioner.components:
parts = partitioner.components
logger.info(
"Using components attribute to save Superblocks to geodatapackage %s", filepath
"Using components attribute to save Superblocks to geodatapackage %s",
filepath,
)
elif partitioner.partitions:
parts = partitioner.partitions
logger.info(
"Using partitions attribute to save Superblocks to geodatapackage %s", filepath
"Using partitions attribute to save Superblocks to geodatapackage %s",
filepath,
)

if not isinstance(parts, list):
Expand Down

0 comments on commit cb3f1d3

Please sign in to comment.