Skip to content

Commit

Permalink
estimation mode usability
Browse files Browse the repository at this point in the history
  • Loading branch information
dhensle committed Mar 11, 2024
1 parent 6d817be commit ece02a8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion activitysim/abm/models/stop_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def stop_frequency(
print(f"survey_trips_not_in_trips\n{survey_trips_not_in_trips}")
different = True
trips_not_in_survey_trips = trips[~trips.index.isin(survey_trips.index)]
if len(survey_trips_not_in_trips) > 0:
if len(trips_not_in_survey_trips) > 0:
print(f"trips_not_in_survey_trips\n{trips_not_in_survey_trips}")
different = True
assert not different
Expand Down
16 changes: 15 additions & 1 deletion activitysim/core/estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ def write_omnibus_table(self):
if len(self.omnibus_tables) == 0:
return

settings = config.read_model_settings(ESTIMATION_SETTINGS_FILE_NAME)

edbs_to_skip = settings.get("SKIP_BUNDLE_WRITE_FOR", [])
if self.bundle_name in edbs_to_skip:
self.debug(f"Skipping write to disk for {self.bundle_name}")
return

for omnibus_table, table_names in self.omnibus_tables.items():
self.debug(
"write_omnibus_table: %s table_names: %s" % (omnibus_table, table_names)
Expand All @@ -237,12 +244,19 @@ def write_omnibus_table(self):
1 if omnibus_table in self.omnibus_tables_append_columns else 0
)

df = pd.concat([self.tables[t] for t in table_names], axis=concat_axis)
if len(table_names) == 0:
# empty tables
df = pd.DataFrame()
else:
df = pd.concat([self.tables[t] for t in table_names], axis=concat_axis)

self.debug(f"sorting tables: {table_names}")
df.sort_index(ascending=True, inplace=True, kind="mergesort")

file_path = self.output_file_path(omnibus_table, "csv")
assert not os.path.isfile(file_path)

self.debug(f"writing table: {file_path}")
df.to_csv(file_path, mode="a", index=True, header=True)

self.debug("write_omnibus_choosers: %s" % file_path)
Expand Down
6 changes: 6 additions & 0 deletions activitysim/estimation/larch/location_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ def _file_exists(filename):
.set_index("segment")
)
size_spec = size_spec.loc[:, size_spec.max() > 0]
assert (
len(size_spec) > 0
), f"Empty size_spec, is model_selector {SIZE_TERM_SELECTOR} in your size term file?"

size_coef = size_coefficients_from_spec(size_spec)

Expand Down Expand Up @@ -294,6 +297,9 @@ def split(a, n):
else:
av = 1

assert len(x_co) > 0, "Empty chooser dataframe"
assert len(x_ca_1) > 0, "Empty alternatives dataframe"

d = DataFrames(co=x_co, ca=x_ca_1, av=av)

m = Model(dataservice=d)
Expand Down

0 comments on commit ece02a8

Please sign in to comment.