Open ulfaslak opened 5 years ago
yeah, this is because I have not made vectors opaque yet (see https://pybind11.readthedocs.io/en/stable/advanced/cast/stl.html?highlight=list#making-opaque-types )... I don't feel comfortable doing that atm because I don't understand the consequences yet. So far, the method of choice would be to construct a list and then pass that list to the edge_lists
-instance as
# Setup
tn = tc.edge_lists()
tn.N = num_nodes
tn.t = list(range(num_timesteps))
tn.tmax = num_timesteps
edges = []
# 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))
edges.append(edges_t)
tn.edges = edges
(see also here: http://rocs.hu-berlin.de/~tacoma/temporal_networks/construction_example.html )
I'll see whether I can raise an exception somehow, not sure how to do this.
Commonly I will have some code like the following:
As indicated by the last comment, appending to
tn.edges
like this does nothing so after the loop has runtn.edges == []
. Also no error is raised. Instead, when trying to doedge_activity_plot(tn)
I receivedValueError: min() arg is an empty sequence
Easy to reproduce just set
tn.edges = []
and calledge_activity_plot(tn)
. I recommend either raising an error when appending totn.edges
, or enabling appending totn.edges
somehow.