Skip to content

Commit 2aded62

Browse files
committed
blacken
1 parent 7f8c511 commit 2aded62

File tree

4 files changed

+42
-18
lines changed

4 files changed

+42
-18
lines changed

activitysim/abm/models/trip_destination.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
)
3131
from activitysim.core.configuration.base import PreprocessorSettings
3232
from activitysim.core.configuration.logit import LocationComponentSettings
33+
from activitysim.core.exceptions import DuplicateWorkflowTableError, InvalidTravelError
3334
from activitysim.core.interaction_sample import interaction_sample
3435
from activitysim.core.interaction_sample_simulate import interaction_sample_simulate
3536
from activitysim.core.skim_dictionary import DataFrameMatrix
3637
from activitysim.core.tracing import print_elapsed_time
3738
from activitysim.core.util import assign_in_place, reindex
38-
from activitysim.core.exceptions import InvalidTravelError, DuplicateWorkflowTableError
3939

4040
logger = logging.getLogger(__name__)
4141

@@ -280,7 +280,9 @@ def aggregate_size_term_matrix(maz_size_term_matrix, network_los, all_tazs=None)
280280
dest_taz = network_los.map_maz_to_taz(df.index)
281281
taz_size_term_matrix = df.groupby(dest_taz).sum()
282282
if all_tazs is not None:
283-
taz_size_term_matrix = taz_size_term_matrix.reindex(all_tazs, fill_value=0).rename_axis(taz_size_term_matrix.index.name, axis=0)
283+
taz_size_term_matrix = taz_size_term_matrix.reindex(
284+
all_tazs, fill_value=0
285+
).rename_axis(taz_size_term_matrix.index.name, axis=0)
284286

285287
taz_size_term_matrix = DataFrameMatrix(taz_size_term_matrix)
286288

@@ -621,7 +623,9 @@ def destination_presample(
621623
else:
622624
all_tazs = None
623625

624-
TAZ_size_term_matrix = aggregate_size_term_matrix(size_term_matrix, network_los, all_tazs)
626+
TAZ_size_term_matrix = aggregate_size_term_matrix(
627+
size_term_matrix, network_los, all_tazs
628+
)
625629

626630
TRIP_ORIGIN = model_settings.TRIP_ORIGIN
627631
PRIMARY_DEST = model_settings.PRIMARY_DEST
@@ -643,7 +647,9 @@ def destination_presample(
643647
# as a vector which will need to align with the TAZ skims.
644648
if state.settings.sharrow:
645649
all_tazs = state.get_dataframe("land_use_taz").index
646-
alternatives = alternatives.reindex(all_tazs, fill_value=0).rename_axis(alternatives.index.name, axis=0)
650+
alternatives = alternatives.reindex(all_tazs, fill_value=0).rename_axis(
651+
alternatives.index.name, axis=0
652+
)
647653

648654
# # i did this but after changing alt_dest_col_name to 'trip_dest' it
649655
# # shouldn't be needed anymore
@@ -1538,13 +1544,13 @@ def run_trip_destination(
15381544
"""
15391545
15401546
When using the trip destination model with sharrow, it is necessary
1541-
to set a value for `purpose_index_num` in the trip destination
1542-
annotate trips preprocessor. This allows for an optimized compiled
1547+
to set a value for `purpose_index_num` in the trip destination
1548+
annotate trips preprocessor. This allows for an optimized compiled
15431549
lookup of the size term from the array of size terms. The value of
1544-
`purpose_index_num` should be the integer column position in the size
1545-
matrix, with usual zero-based numpy indexing semantics (i.e. the first
1550+
`purpose_index_num` should be the integer column position in the size
1551+
matrix, with usual zero-based numpy indexing semantics (i.e. the first
15461552
column is zero). The preprocessor expression most likely needs to be
1547-
"size_terms.get_cols(df.purpose)" unless some unusual transform of
1553+
"size_terms.get_cols(df.purpose)" unless some unusual transform of
15481554
size terms has been employed.
15491555
15501556
"""
Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
1-
from pathlib import Path
1+
from __future__ import annotations
2+
23
import shutil
3-
from activitysim import abm # noqa: F401
4+
from pathlib import Path
5+
46
import pandas as pd
57

8+
from activitysim import abm # noqa: F401
69
from activitysim.core import workflow as wf
710

811

912
def test_trip_destination(tmp_path: Path):
10-
shutil.copytree(Path(__file__).parent.joinpath("configs"), tmp_path.joinpath("configs"))
13+
shutil.copytree(
14+
Path(__file__).parent.joinpath("configs"), tmp_path.joinpath("configs")
15+
)
1116
shutil.copytree(Path(__file__).parent.joinpath("data"), tmp_path.joinpath("data"))
1217

1318
state = wf.State.make_default(working_dir=tmp_path)
1419

1520
# init tours
16-
tours = pd.read_csv(tmp_path / state.filesystem.data_dir[0] / "tours.csv").set_index("tour_id")
21+
tours = pd.read_csv(
22+
tmp_path / state.filesystem.data_dir[0] / "tours.csv"
23+
).set_index("tour_id")
1724
state.add_table("tours", tours)
1825
state.tracing.register_traceable_table("tours", tours)
1926
state.get_rn_generator().add_channel("tours", tours)
2027

2128
# init trips
22-
trips = pd.read_csv(tmp_path / state.filesystem.data_dir[0] / "trips.csv").set_index("trip_id")
29+
trips = pd.read_csv(
30+
tmp_path / state.filesystem.data_dir[0] / "trips.csv"
31+
).set_index("trip_id")
2332
state.add_table("trips", trips)
2433
state.tracing.register_traceable_table("trips", trips)
2534
state.get_rn_generator().add_channel("trips", trips)
@@ -29,4 +38,11 @@ def test_trip_destination(tmp_path: Path):
2938
out_trips = state.get_dataframe("trips")
3039

3140
# logsums are generated for intermediate trips only
32-
assert out_trips["destination_logsum"].isna().tolist() == [True, False, True, True, False, True]
41+
assert out_trips["destination_logsum"].isna().tolist() == [
42+
True,
43+
False,
44+
True,
45+
True,
46+
False,
47+
True,
48+
]

activitysim/core/los.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,10 @@ def load_data(self):
497497
else: # SkimDataset
498498
assert len(skims.dataset.indexes["otaz"]) == len(
499499
self.state.get_dataframe("land_use_taz")
500-
), f"land_use_taz table length {len(self.state.get_dataframe('land_use_taz'))} does not match " \
501-
f"taz skim length {len(skims.dataset.indexes['otaz'])}"
500+
), (
501+
f"land_use_taz table length {len(self.state.get_dataframe('land_use_taz'))} does not match "
502+
f"taz skim length {len(skims.dataset.indexes['otaz'])}"
503+
)
502504

503505
def create_skim_dict(self, skim_tag, _override_offset_int=None):
504506
"""

activitysim/core/skim_dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ def load_sparse_maz_skims(
594594
maz_to_maz_tables=(),
595595
max_blend_distance=None,
596596
data_file_resolver=None,
597-
max_float_precision:int = 32,
597+
max_float_precision: int = 32,
598598
):
599599
"""
600600
Load sparse MAZ data on top of TAZ skim data.

0 commit comments

Comments
 (0)