Skip to content

Commit

Permalink
test app init of examples (#2491)
Browse files Browse the repository at this point in the history
test app init of examples

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jan Kwakkel <j.h.kwakkel@tudelft.nl>
  • Loading branch information
3 people authored and EwoutH committed Nov 11, 2024
1 parent 8d7479b commit b1381c4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mesa/examples/advanced/wolf_sheep/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def post_process_lines(ax):
)

simulator = ABMSimulator()
model = WolfSheep(simulator, grass=True)
model = WolfSheep(simulator=simulator, grass=True)

page = SolaraViz(
model,
Expand Down
2 changes: 1 addition & 1 deletion mesa/visualization/solara_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def do_reset():
running.value = True
simulator.reset()
model.value = model.value = model.value.__class__(
simulator, **model_parameters.value
simulator=simulator, **model_parameters.value
)

def do_play_pause():
Expand Down
35 changes: 35 additions & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,61 +13,96 @@


def test_boltzmann_model(): # noqa: D103
from mesa.examples.basic.boltzmann_wealth_model import app

app.page # noqa: B018

model = BoltzmannWealth(seed=42)

for _i in range(10):
model.step()


def test_conways_game_model(): # noqa: D103
from mesa.examples.basic.conways_game_of_life import app

app.page # noqa: B018

model = ConwaysGameOfLife(seed=42)
for _i in range(10):
model.step()


def test_schelling_model(): # noqa: D103
from mesa.examples.basic.schelling import app

app.page # noqa: B018

model = Schelling(seed=42)
for _i in range(10):
model.step()


def test_virus_on_network(): # noqa: D103
from mesa.examples.basic.virus_on_network import app

app.page # noqa: B018

model = VirusOnNetwork(seed=42)
for _i in range(10):
model.step()


def test_boid_flockers(): # noqa: D103
from mesa.examples.basic.boid_flockers import app

app.page # noqa: B018

model = BoidFlockers(seed=42)

for _i in range(10):
model.step()


def test_epstein(): # noqa: D103
from mesa.examples.advanced.epstein_civil_violence import app

app.page # noqa: B018

model = EpsteinCivilViolence(seed=42)

for _i in range(10):
model.step()


def test_pd_grid(): # noqa: D103
from mesa.examples.advanced.pd_grid import app

app.page # noqa: B018

model = PdGrid(seed=42)

for _i in range(10):
model.step()


def test_sugarscape_g1mt(): # noqa: D103
from mesa.examples.advanced.sugarscape_g1mt import app

app.page # noqa: B018

model = SugarscapeG1mt(seed=42)

for _i in range(10):
model.step()


def test_wolf_sheep(): # noqa: D103
from mesa.examples.advanced.wolf_sheep import app
from mesa.experimental.devs import ABMSimulator

app.page # noqa: B018

simulator = ABMSimulator()
WolfSheep(seed=42, simulator=simulator)
simulator.run_for(10)

0 comments on commit b1381c4

Please sign in to comment.