Skip to content

Commit

Permalink
Explicit datacollector import
Browse files Browse the repository at this point in the history
  • Loading branch information
EwoutH committed Sep 20, 2024
1 parent 3149f91 commit 3b726dd
Show file tree
Hide file tree
Showing 22 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion examples/bank_reserves/bank_reserves/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def __init__(
self.rich_threshold = rich_threshold
self.reserve_percent = reserve_percent
# see datacollector functions above
self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
model_reporters={
"Rich": get_num_rich_agents,
"Poor": get_num_poor_agents,
Expand Down
2 changes: 1 addition & 1 deletion examples/bank_reserves/batch_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def __init__(
self.rich_threshold = rich_threshold
self.reserve_percent = reserve_percent
# see datacollector functions above
self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
model_reporters={
"Rich": get_num_rich_agents,
"Poor": get_num_poor_agents,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, N=100, width=10, height=10):
self.num_agents = N
self.grid = mesa.space.MultiGrid(width, height, True)

self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
model_reporters={"Gini": compute_gini}, agent_reporters={"Wealth": "wealth"}
)
# Create agents
Expand Down
2 changes: 1 addition & 1 deletion examples/boltzmann_wealth_model_experimental/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, N=100, width=10, height=10):
self.num_agents = N
self.grid = mesa.space.MultiGrid(width, height, True)

self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
model_reporters={"Gini": compute_gini}, agent_reporters={"Wealth": "wealth"}
)
# Create agents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, num_agents=7, num_nodes=10):
self.G = nx.erdos_renyi_graph(n=self.num_nodes, p=0.5)
self.grid = mesa.space.NetworkGrid(self.G)

self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
model_reporters={"Gini": compute_gini},
agent_reporters={"Wealth": lambda _: _.wealth},
)
Expand Down
2 changes: 1 addition & 1 deletion examples/caching_and_replay/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(
self.grid = mesa.space.SingleGrid(width, height, torus=True)

self.happy = 0
self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
model_reporters={"happy": "happy"}, # Model-level count of happy agents
)

Expand Down
2 changes: 1 addition & 1 deletion examples/charts/charts/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __init__(
self.rich_threshold = rich_threshold
self.reserve_percent = reserve_percent
# see datacollector functions above
self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
model_reporters={
"Rich": get_num_rich_agents,
"Poor": get_num_poor_agents,
Expand Down
2 changes: 1 addition & 1 deletion examples/el_farol/el_farol/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(
for _ in range(self.num_agents):
BarCustomer(self, memory_size, crowd_threshold, num_strategies)

self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
model_reporters={"Customers": "attendance"},
agent_reporters={"Utility": "utility", "Attendance": "attend"},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(
"condition": lambda a: getattr(a, "condition", None),
"arrest_probability": lambda a: getattr(a, "arrest_probability", None),
}
self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
model_reporters=model_reporters, agent_reporters=agent_reporters
)
if self.cop_density + self.citizen_density > 1:
Expand Down
2 changes: 1 addition & 1 deletion examples/forest_fire/forest_fire/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, width=100, height=100, density=0.65):

self.grid = mesa.space.SingleGrid(width, height, torus=False)

self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
{
"Fine": lambda m: self.count_type(m, "Fine"),
"On Fire": lambda m: self.count_type(m, "On Fire"),
Expand Down
2 changes: 1 addition & 1 deletion examples/pd_grid/pd_grid/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(
self.grid.place_agent(agent, (x, y))
self.schedule.add(agent)

self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
{
"Cooperating_Agents": lambda m: len(
[a for a in m.schedule.agents if a.move == "C"]
Expand Down
2 changes: 1 addition & 1 deletion examples/schelling/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(
self.grid = mesa.space.SingleGrid(width, height, torus=True)

self.happy = 0
self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
model_reporters={"happy": "happy"}, # Model-level count of happy agents
)

Expand Down
2 changes: 1 addition & 1 deletion examples/schelling_experimental/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, width=20, height=20, density=0.8, minority_pc=0.2, homophily=
self.grid = mesa.space.SingleGrid(width, height, torus=True)

self.happy = 0
self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
{"happy": "happy"}, # Model-level count of happy agents
)

Expand Down
2 changes: 1 addition & 1 deletion examples/sugarscape_cg/sugarscape_cg/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, width=50, height=50, initial_population=100):

self.schedule = mesa.time.RandomActivationByType(self)
self.grid = mesa.space.MultiGrid(self.width, self.height, torus=False)
self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
{"SsAgent": lambda m: m.schedule.get_type_count(SsAgent)}
)

Expand Down
2 changes: 1 addition & 1 deletion examples/sugarscape_g1mt/sugarscape_g1mt/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(
# initiate mesa grid class
self.grid = mesa.space.MultiGrid(self.width, self.height, torus=False)
# initiate datacollector
self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
model_reporters={
"Trader": lambda m: len(m.agents_by_type[Trader]),
"Trade Volume": lambda m: sum(
Expand Down
2 changes: 1 addition & 1 deletion examples/virus_on_network/virus_on_network/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(
self.recovery_chance = recovery_chance
self.gain_resistance_chance = gain_resistance_chance

self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
{
"Infected": number_infected,
"Susceptible": number_susceptible,
Expand Down
2 changes: 1 addition & 1 deletion examples/wolf_sheep/wolf_sheep/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(
if grass:
collectors["Grass"] = lambda m: len(m.agents_by_type[GrassPatch])

self.datacollector = mesa.DataCollector(collectors)
self.datacollector = mesa.datacollection.DataCollector(collectors)

# Create sheep:
for i in range(self.initial_sheep):
Expand Down
4 changes: 2 additions & 2 deletions gis/agents_and_networks/src/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class AgentsAndNetworks(mesa.Model):
day: int
hour: int
minute: int
datacollector: mesa.DataCollector
datacollector: mesa.datacollection.DataCollector

def __init__(
self,
Expand Down Expand Up @@ -114,7 +114,7 @@ def __init__(
self._load_lakes_and_rivers_from_file(lakes_file, crs=model_crs)
self._load_lakes_and_rivers_from_file(rivers_file, crs=model_crs)

self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
model_reporters={
"time": get_time,
"status_home": partial(get_num_commuters_by_status, status="home"),
Expand Down
2 changes: 1 addition & 1 deletion gis/geo_schelling/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self, density=0.6, minority_pc=0.2, export_data=False):
self.space = mg.GeoSpace(warn_crs_conversion=False)

self.happy = 0
self.datacollector = mesa.DataCollector({"happy": "happy"})
self.datacollector = mesa.datacollection.DataCollector({"happy": "happy"})

self.running = True

Expand Down
2 changes: 1 addition & 1 deletion gis/geo_schelling_points/geo_schelling_points/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, red_percentage=0.5, similarity_threshold=0.5):
self.schedule = mesa.time.RandomActivation(self)
self.space = Nuts2Eu()

self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
{"unhappy": "unhappy", "happy": "happy"}
)

Expand Down
2 changes: 1 addition & 1 deletion gis/geo_sir/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(
self.infection_risk = infection_risk

self.running = True
self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
{
"infected": get_infected_count,
"susceptible": get_susceptible_count,
Expand Down
2 changes: 1 addition & 1 deletion gis/rainfall/rainfall/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self, rain_rate=500, water_height=5, export_data=False, num_steps=2

self.space = CraterLake(crs="epsg:4326", water_height=water_height, model=self)
self.schedule = mesa.time.RandomActivation(self)
self.datacollector = mesa.DataCollector(
self.datacollector = mesa.datacollection.DataCollector(
{
"Total Amount of Water": "water_amount",
"Total Contained": "contained",
Expand Down

0 comments on commit 3b726dd

Please sign in to comment.