From 95e1cd26c78c1fce5426db8d25e5d92b61b8e827 Mon Sep 17 00:00:00 2001 From: Ewout ter Hoeven Date: Thu, 29 Aug 2024 17:59:16 +0200 Subject: [PATCH] remove _advance_time() from benchmark model - Add a few tests - Check that for each example model.steps == 10 --- benchmarks/BoltzmannWealth/boltzmann_wealth.py | 1 - tests/test_examples.py | 1 + tests/test_model.py | 4 +++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/benchmarks/BoltzmannWealth/boltzmann_wealth.py b/benchmarks/BoltzmannWealth/boltzmann_wealth.py index 9faffa2f0c3..f6b1bf3d6f9 100644 --- a/benchmarks/BoltzmannWealth/boltzmann_wealth.py +++ b/benchmarks/BoltzmannWealth/boltzmann_wealth.py @@ -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) diff --git a/tests/test_examples.py b/tests/test_examples.py index e5c0381f065..25b8e0e07b9 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -66,3 +66,4 @@ def test_examples(self): model = model_class() for _ in range(10): model.step() + self.assertEqual(model.steps, 10) diff --git a/tests/test_model.py b/tests/test_model.py index 874d45f935f..837d6b0049a 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -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(): @@ -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):