Example #1
0
def load_environments_ts(equipments, relayout_data_store, figure, kind, scenario):
    """
        Load selected kind of environment for chosen equipments in a scenario.

        Triggered when user click on a equipment displayed in the
        input_assets_selector in the overview layout.
    """
    if relayout_data_store is not None and relayout_data_store['relayout_data']:
        relayout_data = relayout_data_store["relayout_data"]
        layout = figure["layout"]
        new_axis_layout = get_axis_relayout(figure, relayout_data)
        if new_axis_layout is not None:
            layout.update(new_axis_layout)
            return figure

    if kind is None:
        return figure
    if isinstance(equipments, str):
        equipments = [equipments]  # to make pd.series.isin() work

    figure['data'] = common_graph.environment_ts_data(
        kind,
        make_episode(best_agents[scenario]['agent'], scenario),
        equipments
    )

    return figure
Example #2
0
def load_context_data(equipments, relayout_data_store, window, figure, kind,
                      scenario, agent_study):
    if relayout_data_store is not None and relayout_data_store["relayout_data"]:
        relayout_data = relayout_data_store["relayout_data"]
        layout = figure["layout"]
        new_axis_layout = get_axis_relayout(figure, relayout_data)
        if new_axis_layout is not None:
            layout.update(new_axis_layout)
            return figure

    if kind is None:
        return figure
    if isinstance(equipments, str):
        equipments = [equipments]  # to make pd.series.isin() work
    episode = make_episode(agent_study, scenario)
    figure['data'] = common_graph.environment_ts_data(kind, episode,
                                                      equipments)

    if window is not None:
        figure["layout"].update(xaxis=dict(range=window, autorange=False))

    return figure