1414
1515When the collect() method is called, each model-level function is called, with
1616the model as the argument, and the results associated with the relevant
17- variable. Then the agent-level functions are called on each agent in the model
18- scheduler.
17+ variable. Then the agent-level functions are called on each agent.
1918
2019Additionally, other objects can write directly to tables by passing in an
2120appropriate dictionary object for a table row.
3029Finally, DataCollector can create a pandas DataFrame from each collection.
3130
3231The default DataCollector here makes several assumptions:
33- * The model has a schedule object called 'schedule'
34- * The schedule has an agent list called agents
32+ * The model has an agent list called agents
3533 * For collecting agent-level variables, agents must have a unique_id
3634"""
3735import itertools
@@ -65,7 +63,7 @@ def __init__(
6563
6664 Model reporters can take four types of arguments:
6765 1. Lambda function:
68- {"agent_count": lambda m: m.schedule.get_agent_count( )}
66+ {"agent_count": lambda m: len(m.agents )}
6967 2. Method of a class/instance:
7068 {"agent_count": self.get_agent_count} # self here is a class instance
7169 {"agent_count": Model.get_agent_count} # Model here is a class
@@ -178,11 +176,11 @@ def _record_agents(self, model):
178176 rep_funcs = self .agent_reporters .values ()
179177
180178 def get_reports (agent ):
181- _prefix = (agent .model .schedule . steps , agent .unique_id )
179+ _prefix = (agent .model .steps , agent .unique_id )
182180 reports = tuple (rep (agent ) for rep in rep_funcs )
183181 return _prefix + reports
184182
185- agent_records = map (get_reports , model .schedule . agents )
183+ agent_records = map (get_reports , model .agents )
186184 return agent_records
187185
188186 def collect (self , model ):
@@ -205,7 +203,7 @@ def collect(self, model):
205203
206204 if self .agent_reporters :
207205 agent_records = self ._record_agents (model )
208- self ._agent_records [model .schedule . steps ] = list (agent_records )
206+ self ._agent_records [model .steps ] = list (agent_records )
209207
210208 def add_table_row (self , table_name , row , ignore_missing = False ):
211209 """Add a row dictionary to a specific table.
0 commit comments