Skip to content

Commit fd3e3e3

Browse files
Thedore-ChatziioannouThedore-Chatziioannou
authored andcommitted
linting
1 parent 172d8e6 commit fd3e3e3

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

src/pam/cli.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,6 @@ def plan_filter(plan):
670670
logger.info(f"Output saved at {path_population_output}")
671671

672672

673-
674673
@cli.command()
675674
@click.argument("path_population_in", type=click.Path(exists=True))
676675
@click.argument("path_population_out", type=click.Path(exists=False, writable=True))
@@ -693,5 +692,5 @@ def snap_facilities(
693692
path_population_in=path_population_in,
694693
path_population_out=path_population_out,
695694
path_network_geometry=path_network_geometry,
696-
link_id_field=link_id_field
697-
)
695+
link_id_field=link_id_field,
696+
)

src/pam/operations/snap.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99

1010
def snap_facilities_to_network(
11-
population: Population,
12-
network: gp.GeoDataFrame,
13-
link_id_field: str = "id"
11+
population: Population, network: gp.GeoDataFrame, link_id_field: str = "id"
1412
) -> None:
1513
"""Snaps activity facilities to a network geometry (in-place).
1614
@@ -25,12 +23,13 @@ def snap_facilities_to_network(
2523
link_id = link_ids[network.distance(act.location.loc).argmin()]
2624
act.location.link = link_id
2725

26+
2827
def run_facility_link_snapping(
29-
path_population_in: str,
30-
path_population_out: str,
31-
path_network_geometry: str,
32-
link_id_field: str = "id"
33-
)->None:
28+
path_population_in: str,
29+
path_population_out: str,
30+
path_network_geometry: str,
31+
link_id_field: str = "id",
32+
) -> None:
3433
"""Reads a population, snaps activity facilities to a network geometry, and saves the results.
3534
3635
Args:
@@ -45,4 +44,4 @@ def run_facility_link_snapping(
4544
else:
4645
network = gp.read_file(path_network_geometry)
4746
snap_facilities_to_network(population=population, network=network, link_id_field=link_id_field)
48-
write_matsim(population=population, plans_path=path_population_out)
47+
write_matsim(population=population, plans_path=path_population_out)

tests/test_29_snap.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
def test_add_snapping_adds_link_attribute(population_heh):
12-
network=gp.read_file(os.path.join(TEST_DATA_DIR, "test_link_geometry.geojson"))
12+
network = gp.read_file(os.path.join(TEST_DATA_DIR, "test_link_geometry.geojson"))
1313
for _, _, person in population_heh.people():
1414
for act in person.activities:
1515
assert act.location.link is None
@@ -19,15 +19,16 @@ def test_add_snapping_adds_link_attribute(population_heh):
1919
for act in person.activities:
2020
assert act.location.link is not None
2121

22+
2223
def test_links_resnapped(tmpdir):
23-
path_out=os.path.join(tmpdir, "pop_snapped.xml")
24+
path_out = os.path.join(tmpdir, "pop_snapped.xml")
2425
run_facility_link_snapping(
25-
path_population_in=os.path.join(TEST_DATA_DIR, "1.plans.xml"),
26-
path_population_out=path_out,
27-
path_network_geometry=os.path.join(TEST_DATA_DIR, "test_link_geometry.geojson")
26+
path_population_in=os.path.join(TEST_DATA_DIR, "1.plans.xml"),
27+
path_population_out=path_out,
28+
path_network_geometry=os.path.join(TEST_DATA_DIR, "test_link_geometry.geojson"),
2829
)
2930
assert os.path.exists(path_out)
3031
pop_snapped = read_matsim(path_out)
3132
for _, _, person in pop_snapped.people():
3233
for act in person.activities:
33-
assert "link-" in act.location.link
34+
assert "link-" in act.location.link

0 commit comments

Comments
 (0)