From 96d4bb6bea5a5e15db6f632c365fa504e94715c2 Mon Sep 17 00:00:00 2001 From: David Hensle <51132108+dhensle@users.noreply.github.com> Date: Mon, 20 May 2024 11:14:30 -0700 Subject: [PATCH] landuse index sort before sharrow recode check --- activitysim/abm/tables/landuse.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/activitysim/abm/tables/landuse.py b/activitysim/abm/tables/landuse.py index 9abc0c2e7..ed7acaf3b 100644 --- a/activitysim/abm/tables/landuse.py +++ b/activitysim/abm/tables/landuse.py @@ -21,6 +21,13 @@ def land_use(state: workflow.State): df = read_input_table(state, "land_use") + # try to make life easy for everybody by keeping everything in canonical order + # but as long as coalesce_pipeline doesn't sort tables it coalesces, it might not stay in order + # so even though we do this, anyone downstream who depends on it, should look out for themselves... + if not df.index.is_monotonic_increasing: + logger.info(f"sorting land_use index") + df = df.sort_index() + sharrow_enabled = state.settings.sharrow if sharrow_enabled: err_msg = ( @@ -34,12 +41,6 @@ def land_use(state: workflow.State): assert df.index[-1] == len(df.index) - 1, err_msg assert df.index.dtype.kind == "i", err_msg - # try to make life easy for everybody by keeping everything in canonical order - # but as long as coalesce_pipeline doesn't sort tables it coalesces, it might not stay in order - # so even though we do this, anyone downstream who depends on it, should look out for themselves... - if not df.index.is_monotonic_increasing: - df = df.sort_index() - logger.info("loaded land_use %s" % (df.shape,)) buffer = io.StringIO() df.info(buf=buffer)