Skip to content

Commit

Permalink
fix and test orig_land_use with explicit chunking
Browse files Browse the repository at this point in the history
  • Loading branch information
jpn-- committed May 7, 2024
1 parent 75d1a1d commit 11a01a7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
3 changes: 2 additions & 1 deletion activitysim/abm/models/accessibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,12 @@ def compute_accessibility(
) in chunk.adaptive_chunked_choosers(
state, accessibility_df, trace_label, explicit_chunk_size=explicit_chunk_size
):
orig_land_use_df_chunk = orig_land_use_df.loc[chooser_chunk.index]
accessibilities = compute_accessibilities_for_zones(
state,
chooser_chunk,
land_use_df,
orig_land_use_df,
orig_land_use_df_chunk,
assignment_spec,
constants,
network_los,
Expand Down
45 changes: 45 additions & 0 deletions activitysim/abm/test/test_agg_accessibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,48 @@ def test_agg_accessibility_explicit_chunking(state, dataframe_regression):
)
df = state.get_dataframe("accessibility")
dataframe_regression.check(df, basename="simple_agg_accessibility")


@pytest.mark.parametrize("explicit_chunk", [0, 5])
def test_agg_accessibility_orig_land_use(
state, dataframe_regression, tmp_path, explicit_chunk
):
# set top level settings
state.settings.chunk_size = 0
state.settings.sharrow = False
state.settings.chunk_training_mode = "explicit"

# read the accessibility settings and override the explicit chunk size to 5
model_settings = AccessibilitySettings.read_settings_file(
state.filesystem, "accessibility.yaml"
)
model_settings.explicit_chunk = explicit_chunk
model_settings.land_use_columns = ["RETEMPN", "TOTEMP", "TOTACRE"]
model_settings.land_use_columns_orig = ["TOTACRE"]

land_use = state.get_dataframe("land_use")
accessibility = state.get_dataframe("accessibility")

tmp_spec = tmp_path / "tmp-accessibility.csv"
tmp_spec.open("w").write(
"""Description,Target,Expression
orig_acreage,orig_acreage,df.landuse_orig_TOTACRE
dest_acreage,dest_acreage,df.TOTACRE
"""
)
model_settings.SPEC = str(tmp_spec)

# state.filesystem.get_config_file_path(model_settings.SPEC)

compute_accessibility(
state,
land_use,
accessibility,
state.get("network_los"),
model_settings,
model_settings_file_name="accessibility.yaml",
trace_label="compute_accessibility",
output_table_name="accessibility",
)
df = state.get_dataframe("accessibility")
dataframe_regression.check(df, basename="simple_agg_accessibility_orig_land_use")

0 comments on commit 11a01a7

Please sign in to comment.