Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions activitysim/core/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def compute_columns(
_locals_dict["skim_dict"] = state.get_injectable("skim_dataset_dict")
else:
_locals_dict["skim_dict"] = state.get_injectable("skim_dict")

_locals_dict["network_los"] = state.get_injectable("network_los")
except FileNotFoundError:
pass # maybe we don't even need the skims

Expand Down
3 changes: 2 additions & 1 deletion activitysim/core/test/configs/preprocessor.csv
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ skim dict test,od_distance,"skim_dict.lookup(df.origin, df.destination, 'DIST')"
skim wrapper test,od_distance_wrapper,skims2d['DIST']
sov time,od_sov_time,skims3d['SOV_TIME']
testing constant from locals_dict,constant_test,test_constant / 2
testing global constant,global_constant_test,global_test_constant / 2
testing global constant,global_constant_test,global_test_constant / 2
network los period label test,los_period,network_los.skim_time_period_label(df.depart)
9 changes: 7 additions & 2 deletions activitysim/core/test/test_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def state() -> workflow.State:
state = add_canonical_dirs("configs_1z").load_settings()
network_los = los.Network_LOS(state)
network_los.load_data()
state.set("network_los", network_los)
state.set("skim_dict", network_los.get_default_skim_dict())
return state

Expand Down Expand Up @@ -71,6 +72,7 @@ def tours():
"origin": [1, 2, 3],
"destination": [2, 3, 1],
"period": ["AM", "PM", "AM"],
"depart": [8, 18, 8],
}
).set_index("tour_id")

Expand All @@ -88,6 +90,7 @@ def check_outputs(tours):
"od_sov_time",
"constant_test",
"global_constant_test",
"los_period",
]

# check all new columns are added
Expand All @@ -101,7 +104,7 @@ def check_outputs(tours):
), f"Unexpected column found: _hh_income in {tours.columns}"

# check the values in the new columns
exppected_output = pd.DataFrame(
expected_output = pd.DataFrame(
{
"tour_id": [1, 2, 3],
"is_high_income": [False, True, True],
Expand All @@ -111,9 +114,11 @@ def check_outputs(tours):
"od_sov_time": [0.78, 0.89, 1.76],
"constant_test": [21, 21, 21],
"global_constant_test": [21, 21, 21],
"los_period": ["AM", "PM", "AM"],
}
).set_index("tour_id")
pd.testing.assert_frame_equal(tours[new_cols], exppected_output, check_dtype=False)
expected_output["los_period"] = expected_output["los_period"].astype("category")
pd.testing.assert_frame_equal(tours[new_cols], expected_output, check_dtype=False)


def setup_skims(state: workflow.State):
Expand Down
Loading