Skip to content

Commit

Permalink
remove _advance_time() from benchmark model
Browse files Browse the repository at this point in the history
- Add a few tests
- Check that for each example model.steps == 10
  • Loading branch information
EwoutH committed Aug 29, 2024
1 parent 80e32d1 commit 95e1cd2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 0 additions & 1 deletion benchmarks/BoltzmannWealth/boltzmann_wealth.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def __init__(self, seed=None, n=100, width=10, height=10):
self.datacollector.collect(self)

def step(self):
self._advance_time()
self.agents.shuffle().do("step")
# collect data
self.datacollector.collect(self)
Expand Down
1 change: 1 addition & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ def test_examples(self):
model = model_class()
for _ in range(10):
model.step()
self.assertEqual(model.steps, 10)
4 changes: 3 additions & 1 deletion tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ def test_model_set_up():
assert model.current_id == 0
assert model.current_id + 1 == model.next_id()
assert model.current_id == 1
assert model.steps == 0
model.step()
assert model.steps == 1


def test_running():
Expand All @@ -18,12 +20,12 @@ class TestModel(Model):

def step(self):
"""Increase steps until 10."""
self.steps += 1
if self.steps == 10:
self.running = False

model = TestModel()
model.run_model()
assert model.steps == 10


def test_seed(seed=23):
Expand Down

0 comments on commit 95e1cd2

Please sign in to comment.