Ejemplo n.º 1
0
    def test_with_run_71(self):

        places = read.read_tidy_csv(
            filename=occ_test_files.files.RUN_71_PLACES,
            node_type="place",
            drop_non_coloured_sums=True)
        transitions = read.read_tidy_csv(
            filename=occ_test_files.files.RUN_71_TRANSITIONS,
            node_type="transition",
            drop_non_coloured_sums=True)
        graph_medium = nx.read_gml(occ_test_files.files.RUN_71_NETWORK_GML,
                                   destringizer=int)

        places = occ.reduction.read.prepend_tidy_frame_with_tstep(places)
        transitions = occ.reduction.read.prepend_tidy_frame_with_tstep(
            transitions)

        place_change_events = generate_place_increased_events(places)
        transition_events = generate_transition_events(transitions)

        causal_graph = generate_causal_graph(place_change_events,
                                             transition_events, 0.1)

        fig = occasion_graph.generate_causal_graph_figure(causal_graph,
                                                          graph_medium,
                                                          style=Style.ORIG)
        if PLOT:
            url = py.plot(fig)
            print(url)
Ejemplo n.º 2
0
def _load_run_77():
    graph_medium = _gen_loop_graph(6)
    places = read.read_tidy_csv(PLACES, 'place', drop_non_coloured_sums=True)
    places = occ.reduction.read.prepend_tidy_frame_with_tstep(places)
    place_change_events = generate_place_increased_events(places)
    transitions = read.read_tidy_csv(TRANSITIONS, 'transition', drop_non_coloured_sums=True)
    transitions = occ.reduction.read.prepend_tidy_frame_with_tstep(transitions)
    transition_events = generate_transition_events(transitions)
    return graph_medium, place_change_events, transition_events
Ejemplo n.º 3
0
def _load_run_100():
    graph_medium = nx.read_gml(occ_test_files.files.RUN_100_GML, destringizer=int)
    places = read.read_tidy_csv(occ_test_files.files.RUN_100_PLACES, 'place', drop_non_coloured_sums=True)
    places = occ.reduction.read.prepend_tidy_frame_with_tstep(places)
    place_change_events = generate_place_increased_events(places)
    transitions = read.read_tidy_csv(occ_test_files.files.RUN_100_TRANSITIONS, 'transition', drop_non_coloured_sums=True)
    transitions = occ.reduction.read.prepend_tidy_frame_with_tstep(transitions)
    transition_events = generate_transition_events(transitions)
    return graph_medium, place_change_events, transition_events
Ejemplo n.º 4
0
def test_generate_network_animation_figure_with_slider():

    places = read_tidy_csv(RUN_71_PLACES, 'place', drop_non_coloured_sums=True)
    places = occ.reduction.read.prepend_tidy_frame_with_tstep(places)
    places.query('time < 8', inplace=True)

    medium_graph = nx.read_gml(RUN_71_NETWORK_GML, destringizer=int)
    medium_layout = nx.spring_layout(medium_graph, dim=2)

    fig = generate_network_animation_figure_with_slider(
        places, medium_graph, medium_layout)
    if PLOT:
        py.plot(fig)
Ejemplo n.º 5
0
def generate_sums_by_state_figure(places_path: Path = None,
                                  places=None,
                                  run_id=None):
    if places_path:
        assert not places
        assert places_path.exists()
        places = read.read_tidy_csv(str(places_path),
                                    'place',
                                    drop_non_coloured_sums=False)
    elif places is not None:
        assert not places_path
    else:
        raise ValueError("Only one of places_path or places should be set")
    non_coloured_sums = places[places.num.isna()]

    state_name_list = list(non_coloured_sums['name'].unique())
    ordered_state_list, color_dict = pyspike.util.generate_state_order_and_colours(
        state_name_list)

    data = []
    for state_name in ordered_state_list:
        color = color_dict[state_name]
        df = non_coloured_sums.query(f"name == '{state_name}'")
        df = df[df['count'].diff() != 0]
        data.append(
            go.Scatter(
                name=render_name(state_name),
                x=df['time'],
                y=df['count'],
                line=dict(color=color,
                          # shape='hv'
                          ),
                mode='lines+markers',
            ))
    title = f"Non coloured sums for run {run_id}" if run_id else "Non coloured sums"

    layout = go.Layout(
        title=title,
        yaxis=dict(title='count'),
        xaxis=dict(
            title='time',
            rangeslider=dict(visible=True),
        ),
        clickmode='event+select',
    )

    # fig = go.Figure(data=data, layout=layout)
    # return fig
    return dict(data=data, layout=layout)
Ejemplo n.º 6
0
 def test_with_are_both_neighbours__func_used(self):
     transitions = read.read_tidy_csv(
         occ_test_files.files.RUN_90_TRANSITIONS, 'transition')
     log([transitions])
Ejemplo n.º 7
0
            # follow1(a, A, 0.2),
            # follow1(A, a, 0.2),
            follow2(a, A, 2),
            follow2(A, a, 2),
"""
RUN_162_PATH = '/Users/walton/Documents/DPhil/proof-of-concept/runs/162'

# %% Plot run 160 data

RUN_DIR = RUN_161_PATH
n_runs = 100

# Load time column
places_path = os.path.join(RUN_DIR, "places.csv")
places = read.read_tidy_csv(str(places_path),
                            'place',
                            drop_non_coloured_sums=False)
time_list = places['time'].unique()

# with columns time, run1
state_name_list = sorted(places['name'].unique())
_, color_dict = pyspike.util.generate_state_order_and_colours(state_name_list)

data = []
for run_num in range(n_runs):
    places_path = os.path.join(RUN_DIR, f"places_{run_num:04d}.csv")
    assert os.path.isfile(places_path)
    places = read.read_tidy_csv(str(places_path),
                                'place',
                                drop_non_coloured_sums=False)
    places_a = places.query("name=='a'")