Skip to content

Commit

Permalink
catch attribute error for iterable thresholds
Browse files Browse the repository at this point in the history
  • Loading branch information
benmaier committed Dec 19, 2020
1 parent e73b211 commit c2f0c90
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion thresholdmodel/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Contains a bunch of information about this package.
"""

__version__ = "0.0.2"
__version__ = "0.0.3"

__author__ = "Benjamin F. Maier"
__copyright__ = "Copyright 2019-2020, Benjamin F. Maier"
Expand Down
17 changes: 9 additions & 8 deletions thresholdmodel/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

class ThreshModel():
"""
A simple simulation class that runs
A simple simulation class that runs
a threshold-model activation process
on a static network (potentially weighted and directed)
in continuous time using Gillespie's
in continuous time using Gillespie's
stochastic simulation algorithm.
The temporal dimension is fixed by assuming
Expand Down Expand Up @@ -98,15 +98,15 @@ class ThreshModel():
(relative to the size of the node set).
Only available after ``simulation()`` was called.
activated_nodes: list
A list of lists.
A list of lists.
Each entry contains a list of integers representing
the nodes that have been activated
the nodes that have been activated
at the corrsponding time value in ``time``.
Each list entry will contain only a single node
for every other time than the initial time.
Only available after ``simulation()`` was called.
"""

def __init__(self,
G,
initially_activated,
Expand Down Expand Up @@ -153,8 +153,9 @@ def set_thresholds(self,thresholds):
thresholds = np.ones(self.N,dtype=float) * thresholds

else:
assert(len(thresholds) == N)
assert(np.all(thresholds <= 1) and np.all(thresholds>=0))
assert(len(thresholds) == self.N)
assert(np.all(np.array(thresholds) <= 1) and \
np.all(np.array(thresholds) >= 0))

self.thresholds = np.array(thresholds,dtype=float) * self.in_deg

Expand Down Expand Up @@ -298,7 +299,7 @@ def simulate(self,save_activated_nodes=False):
N = B**L
k = 10
mu = -0.8
thresholds = 0.1
thresholds = [0.1]*N
initially_infected = np.arange(10)

#G = to_networkx_graph(*modular_hierarchical_network(B,L,k,mu))
Expand Down

0 comments on commit c2f0c90

Please sign in to comment.