Skip to content

Commit f46d5db

Browse files
committed
Revert "Explicit datacollector import"
This reverts commit 37f89d3.
1 parent c2ba763 commit f46d5db

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

benchmarks/BoltzmannWealth/boltzmann_wealth.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""
55

66
import mesa
7-
from mesa.datacollection import DataCollector
87

98

109
def compute_gini(model):
@@ -45,7 +44,7 @@ def __init__(self, seed=None, n=100, width=10, height=10):
4544
self.num_agents = n
4645
self.grid = mesa.space.MultiGrid(width, height, True)
4746
self.schedule = mesa.time.RandomActivation(self)
48-
self.datacollector = DataCollector(
47+
self.datacollector = mesa.DataCollector(
4948
model_reporters={"Gini": compute_gini}, agent_reporters={"Wealth": "wealth"}
5049
)
5150
# Create agents

docs/overview.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,13 @@ You'd add a data collector to the model like this:
7171

7272
```python
7373
import mesa
74-
from mesa.datacollection import DataCollector
7574

7675
# ...
7776

7877
class MyModel(mesa.Model):
7978
def __init__(self, n_agents):
8079
# ...
81-
self.dc = DataCollector(model_reporters={"agent_count":
80+
self.dc = mesa.DataCollector(model_reporters={"agent_count":
8281
lambda m: m.schedule.get_agent_count()},
8382
agent_reporters={"name": lambda a: a.name})
8483

docs/tutorials/MoneyModel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""a simple version of the boltman wealth model"""
22

33
import mesa
4-
from mesa.datacollection import DataCollector
54

65

76
def compute_gini(model):
@@ -72,7 +71,7 @@ def __init__(self, N, width, height):
7271
y = self.random.randrange(self.grid.height)
7372
self.grid.place_agent(a, (x, y))
7473

75-
self.datacollector = DataCollector(
74+
self.datacollector = mesa.DataCollector(
7675
model_reporters={"Gini": compute_gini}, agent_reporters={"Wealth": "wealth"}
7776
)
7877

docs/tutorials/intro_tutorial.ipynb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@
153153
"outputs": [],
154154
"source": [
155155
"import mesa\n",
156-
"from mesa.datacollection import DataCollector\n",
157156
"\n",
158157
"# Data visualization tools.\n",
159158
"import seaborn as sns\n",
@@ -752,7 +751,7 @@
752751
"\n",
753752
"The data collector stores three categories of data: model-level variables, agent-level variables, and tables (which are a catch-all for everything else). Model- and agent-level variables are added to the data collector along with a function for collecting them. Model-level collection functions take a model object as an input, while agent-level collection functions take an agent object as an input. Both then return a value computed from the model or each agent at their current state. When the data collector’s `collect` method is called, with a model object as its argument, it applies each model-level collection function to the model, and stores the results in a dictionary, associating the current value with the current step of the model. Similarly, the method applies each agent-level collection function to each agent currently in the schedule, associating the resulting value with the step of the model, and the agent’s `unique_id`.\n",
754753
"\n",
755-
"Let's add a [`DataCollector`](https://github.com/projectmesa/mesa/blob/main/mesa/datacollection.py) to the model and collect two variables. At the agent level, we want to collect every agent's wealth at every step. At the model level, let's measure the model's [Gini Coefficient](https://en.wikipedia.org/wiki/Gini_coefficient), a measure of wealth inequality."
754+
"Let's add a DataCollector to the model with [`mesa.DataCollector`](https://github.com/projectmesa/mesa/blob/main/mesa/datacollection.py), and collect two variables. At the agent level, we want to collect every agent's wealth at every step. At the model level, let's measure the model's [Gini Coefficient](https://en.wikipedia.org/wiki/Gini_coefficient), a measure of wealth inequality."
756755
]
757756
},
758757
{
@@ -819,7 +818,7 @@
819818
" y = self.random.randrange(self.grid.height)\n",
820819
" self.grid.place_agent(a, (x, y))\n",
821820
"\n",
822-
" self.datacollector = DataCollector(\n",
821+
" self.datacollector = mesa.DataCollector(\n",
823822
" model_reporters={\"Gini\": compute_gini}, agent_reporters={\"Wealth\": \"wealth\"}\n",
824823
" )\n",
825824
"\n",
@@ -1061,7 +1060,7 @@
10611060
" y = self.random.randrange(self.grid.height)\n",
10621061
" self.grid.place_agent(a, (x, y))\n",
10631062
"\n",
1064-
" self.datacollector = DataCollector(\n",
1063+
" self.datacollector = mesa.DataCollector(\n",
10651064
" model_reporters={\"Gini\": compute_gini},\n",
10661065
" agent_reporters={\"Wealth\": \"wealth\", \"Steps_not_given\": \"steps_not_given\"},\n",
10671066
" )\n",

0 commit comments

Comments
 (0)