Skip to content

Commit

Permalink
fix assertion; cast division -> int; make explicit None comparison (n…
Browse files Browse the repository at this point in the history
…p.array)
  • Loading branch information
fabridamicelli committed Feb 13, 2021
1 parent f395463 commit e690f7e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions kuramoto.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ def __init__(self, coupling=1, dt=0.01, T=10, n_nodes=None, natfreqs=None):
Must be specified if n_nodes is not given.
If given, it overrides the n_nodes argument.
'''
assert n_nodes is not None and natfreqs is not None, \
'n_nodes or natfreqs must be specified'
if n_nodes is None and natfreqs is None:
raise ValueError("n_nodes or natfreqs must be specified")

self.dt = dt
self.T = T
self.coupling = coupling

if natfreqs:
if natfreqs is not None:
self.natfreqs = natfreqs
self.n_nodes = len(natfreqs)
else:
Expand Down Expand Up @@ -59,7 +60,7 @@ def derivative(self, angles_vec, t, adj_mat):

def integrate(self, angles_vec, adj_mat):
'''Updates all states by integrating state of all nodes'''
t = np.linspace(0, self.T, self.T/self.dt)
t = np.linspace(0, self.T, int(self.T/self.dt))
timeseries = odeint(self.derivative, angles_vec, t, args=(adj_mat,))
return timeseries.T # transpose for consistency (act_mat:node vs time)

Expand Down

0 comments on commit e690f7e

Please sign in to comment.