-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from mariuzka/mk/fix_dummy_model_error
Mk/fix dummy model error
- Loading branch information
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import networkx as nx | ||
|
||
import pop2net as p2n | ||
|
||
|
||
def test_p_transfer(): | ||
"""Tests whether a MagicLocation can access the parameters p of the model | ||
when the Creator is working.""" | ||
|
||
class TestLocation(p2n.MagicLocation): | ||
def __init__(self, model: p2n.Model) -> None: | ||
super().__init__(model) | ||
self.nxgraph = nx.cycle_graph(n=self.p["n_agents"]) | ||
|
||
class TestModel(p2n.Model): | ||
def setup(self): | ||
self.creator = p2n.Creator(model=self) | ||
self.creator.create_agents(n=self.p["n_agents"]) | ||
self.creator.create_locations(location_classes=[TestLocation]) | ||
|
||
params = {"n_agents": 100} | ||
|
||
model = TestModel(parameters=params) | ||
model.run(steps=3) | ||
|
||
assert len(model.agents) == 100 |