helper_func module

helper_func.activity_colors(list_act: Optional[List] = None, palette: str = 'colorblind') List[source]

Match each activity from list to a color from the input palette. Useful to keep consistent colors across visualizations

  • list_act: list of activity all_labels

  • palette; name of matplotlib/searborn color palette.

helper_func.discretize_sched(schedule: DataFrame, block_size: float = 0.5) Dict[source]

Discretizes given schedule in blocks of size (duration) n

-schedule: schedule as a pandas dataframe -block_size: discretization in hours

Return type:

Schedule as a dictionary, where keys are the chosen discretization.

helper_func.generate_discret_sched(block_size: float = 0.25, list_act: Optional[List] = None) Dict[source]

Returns a random 24h schedule discretized in blocks of size (duration) n

  • Block_size: expressed in hours

  • list_act: If a list of activities is passed, then all the activities of the list are scheduled. Otherwise,

schedules are generated randomly from the default list of activities.

  • Random schedule as a dictionary

helper_func.lookup_discret() DataFrame[source]

Precomputed table to convert one time discretisation to another.

helper_func.parse_df_schedule(schedule: DataFrame, tt_mat: Optional[Dict] = None) Schedule[source]

Transforms a pandas DataFrame schedule into a Schedule object.

  • schedule: dataframe schedule

  • tt_mat: travel time matrix

Schedule object

helper_func.parse_schedule(schedule: Dict) Schedule[source]

Transforms a dictionary schedule into a Schedule object.

  • schedule: dataframe schedule

  • tt_mat: travel time matrix

Schedule object

helper_func.round_nearest(x: float, a: int) int[source]

Rounds x to nearest integer a

helper_func.sched_from_dict(dict_sched: Dict) DataFrame[source]

Creates a pandas DataFrame schedule from a dictionary

helper_func.schedule_to_pandas(schedule: Schedule) DataFrame[source]

Transform a Schedule object in a Pandas dataframe.

-schedule: Schedule object

Schedule as a pandas DataFrame.