Skip to content

Commit

Permalink
Two small fixes and black file auto-formatting. (#328)
Browse files Browse the repository at this point in the history
* Fix integrator in continuous time Lotka Volterra model.
* apply black auto-formatter
  • Loading branch information
djpasseyjr committed Mar 29, 2023
1 parent 4498934 commit c1c85aa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion netrd/dynamics/lotka_volterra.py
Expand Up @@ -143,7 +143,7 @@ def dyn(t, state):
integrator = ode(dyn).set_integrator('dopri5')
integrator.set_initial_value(init, 0.0)
for t in range(L - 1):
if integrator.succesful():
if integrator.successful():
TS[:, t + 1] = integrator.integrate(integrator.t + dt[t])
else:
message = 'Integration not succesful. '
Expand Down
9 changes: 9 additions & 0 deletions tests/test_dynamics.py
Expand Up @@ -9,6 +9,7 @@
import networkx as nx
from netrd import dynamics
from netrd.dynamics import BaseDynamics
from netrd.dynamics import LotkaVolterra


def test_dynamics_valid_dimensions():
Expand All @@ -25,3 +26,11 @@ def test_dynamics_valid_dimensions():

assert BaseDynamics().simulate(G, 25).shape == (N, 25)
assert BaseDynamics().simulate(G, 100).shape == (N, 100)


def test_lotka_volterra():
"""Test Lotka Volterra simulation"""
g = nx.fast_gnp_random_graph(10, 0.001)
lv_model = LotkaVolterra()
assert lv_model.simulate(g, 100, stochastic=False).shape == (10, 100)
assert lv_model.simulate(g, 100, stochastic=False).shape == (10, 100)

0 comments on commit c1c85aa

Please sign in to comment.