Skip to content

Commit

Permalink
improve formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jpn-- committed Apr 4, 2022
1 parent b051bbb commit ed3a529
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 3 deletions.
17 changes: 17 additions & 0 deletions activitysim/workflows/example_runner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,39 @@ reporting:
title: "{example_name} report"
common_directory: "{workspace}/{example_name}"


#### Runtime and Data Inventory ####

- name: activitysim.workflows.steps.contrast.runtime
in:
common_output_directory: "{workspace}/{example_name}/output-{tag}"

- name: activitysim.workflows.steps.contrast.data_inventory


#### Trip Mode Choice ####

- name: activitysim.workflows.steps.contrast.section_title
in:
title: Trip Mode Choice

- name: activitysim.workflows.steps.contrast.trip_mode_choice
in:
title: Trip Mode Choice by Primary Purpose
title_level: 3
grouping: primary_purpose

- name: activitysim.workflows.steps.contrast.trip_mode_choice
in:
title: Trip Mode Choice by Departure Time
title_level: 3
grouping: depart


#### ####


################################################################################
report-save:
- name: activitysim.workflows.steps.contrast.save_report
in:
Expand Down
7 changes: 6 additions & 1 deletion activitysim/workflows/steps/contrast/data_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ def run_step(context: Context) -> None:
with report:
with pd.option_context('display.max_rows', 1_000_000, 'display.max_columns', 10_000):
report << tab("Table Contents", level=3)
report << pd.DataFrame(dtypes).rename_axis(index=['table','column']).fillna("")
dtypes_table = pd.DataFrame(dtypes).rename_axis(index=['table','column']).fillna("")
dtypes_table[""] = pd.Series(
(dtypes_table.iloc[:, 0].to_frame().values == dtypes_table.values).all(1),
index=dtypes_table.index,
).apply(lambda x: "" if x else "\u2B05")
report << dtypes_table


26 changes: 26 additions & 0 deletions activitysim/workflows/steps/contrast/section_title.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

import logging
from pypyr.context import Context
from pypyr.errors import KeyNotInContextError
from ..error_handler import error_logging

logger = logging.getLogger(__name__)


@error_logging
def run_step(context: Context) -> None:

context.assert_key_has_value(key='report', caller=__name__)
report = context.get('report')

title = context.get_formatted('title')
try:
level = context.get_formatted('level')
except (KeyError, KeyNotInContextError):
level = 2

with report:
t = "#" * level
report << f"{t} {title}"


5 changes: 3 additions & 2 deletions activitysim/workflows/steps/contrast/trip_mode_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ def run_step(context: Context) -> None:
contrast_data = context.get('contrast_data')
grouping = context.get_formatted('grouping')
title = context.get_formatted('title')
title_level = context.get('title_level', None)

reset_progress_step(description=f"report trip mode choice / {grouping}")

with report:
report << fig(title)
report << fig(title, level=title_level)
report << compare_trip_mode_choice(contrast_data, title=None, grouping=grouping)


Expand Down Expand Up @@ -58,7 +59,7 @@ def compare_trip_mode_choice(tablesets, title="Trip Mode Choice", grouping='prim
).encode(
color='trip_mode',
y=alt.Y('source', axis=alt.Axis(grid=False, title='')),
x=alt.X('share_trips', axis=alt.Axis(grid=False, labels=False, title='Mode Share')),
x=alt.X('share_trips', axis=alt.Axis(grid=False, labels=False, title='Mode Share'), scale=alt.Scale(domain=[0., 1.])),
row=grouping,
opacity=alt.condition(selection, alt.value(1), alt.value(0.2)),
tooltip = ['trip_mode', 'source', 'n_trips', alt.Tooltip('share_trips:Q', format='.2%')],
Expand Down

0 comments on commit ed3a529

Please sign in to comment.