Skip to content

tn.edges does not support .append method #20

@ulfaslak

Description

@ulfaslak

Commonly I will have some code like the following:

# Setup
tn = tc.edge_lists()
tn = num_nodes
tn = list(range(num_timesteps))
tn = num_timesteps

# Add edges conditional on criterion
for t in range(0, num_timesteps):
    edges_t = []
    for i in range(num_nodes):
        for j in range(i+1, num_nodes):
            if some_criterion(i, j):
                edges_t.append((i, j))
    tn.edges.append(edges_t)  # <-- `edges_t` DOESN'T ACTUALLY APPEND TO `tn.edges`

As indicated by the last comment, appending to tn.edges like this does nothing so after the loop has run tn.edges == []. Also no error is raised. Instead, when trying to do edge_activity_plot(tn) I received ValueError: min() arg is an empty sequence

Easy to reproduce just set tn.edges = [] and call edge_activity_plot(tn). I recommend either raising an error when appending to tn.edges, or enabling appending to tn.edges somehow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C++-corebugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions