Skip to content

Commit 428c900

Browse files
rhttpike3
andauthored
Bump to Mesa 2.0 (#40)
* Bump to Mesa 2.0 * Update to Mesa 2.0 API * Update coord_iter to Mesa 2.0 API --------- Co-authored-by: Tom Pike <tpike3@gmu.edu>
1 parent db2ec03 commit 428c900

File tree

31 files changed

+40
-41
lines changed

31 files changed

+40
-41
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
itertools
2-
mesa~=1.1
2+
mesa~=2.0
33
numpy
44
pandas
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
jupyter
22
matplotlib
3-
mesa~=1.1
3+
mesa~=2.0

examples/boltzmann_wealth_model/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
my_bar.progress((i / num_ticks), text="Simulation progress")
6969
placeholder.text("Step = %d" % i)
7070
for cell in model.grid.coord_iter():
71-
cell_content, x, y = cell
71+
cell_content, (x, y) = cell
7272
agent_count = len(cell_content)
7373
selected_row = df_grid[(df_grid["x"] == x) & (df_grid["y"] == y)]
7474
df_grid.loc[
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
mesa~=1.1
1+
mesa~=2.0
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
mesa~=1.1
2-
-e git+https://github.com/projectmesa/mesa-examples
1+
mesa~=2.0
2+
solara
3+
git+https://github.com/projectmesa/mesa-examples

examples/boltzmann_wealth_model_network/boltzmann_wealth_model_network/model.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,15 @@ def __init__(self, unique_id, model):
5656
def move(self):
5757
possible_steps = [
5858
node
59-
for node in self.model.grid.get_neighbors(self.pos, include_center=False)
59+
for node in self.model.grid.get_neighborhood(self.pos, include_center=False)
6060
if self.model.grid.is_cell_empty(node)
6161
]
6262
if len(possible_steps) > 0:
6363
new_position = self.random.choice(possible_steps)
6464
self.model.grid.move_agent(self, new_position)
6565

6666
def give_money(self):
67-
neighbors_nodes = self.model.grid.get_neighbors(self.pos, include_center=False)
68-
neighbors = self.model.grid.get_cell_list_contents(neighbors_nodes)
67+
neighbors = self.model.grid.get_neighbors(self.pos, include_center=False)
6968
if len(neighbors) > 0:
7069
other = self.random.choice(neighbors)
7170
other.wealth += 1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
jupyter
22
matplotlib
3-
mesa~=1.1
3+
mesa~=2.0
44
numpy
55
networkx

examples/caching_and_replay/model.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ def __init__(self, width=20, height=20, density=0.8, minority_pc=0.2, homophily=
6363
# the coordinates of a cell as well as
6464
# its contents. (coord_iter)
6565
for cell in self.grid.coord_iter():
66-
x = cell[1]
67-
y = cell[2]
66+
x, y = cell[1]
6867
if self.random.random() < self.density:
6968
agent_type = 1 if self.random.random() < self.minority_pc else 0
7069

examples/charts/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
itertools
2-
mesa~=1.1
2+
mesa~=2.0
33
numpy
44
pandas

examples/color_patches/color_patches/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(self, width=20, height=20):
8080
# -->but only col & row
8181
# for (contents, col, row) in self._grid.coord_iter():
8282
# replaced content with _ to appease linter
83-
for _, row, col in self._grid.coord_iter():
83+
for _, (row, col) in self._grid.coord_iter():
8484
cell = ColorCell(
8585
(row, col), self, ColorCell.OPINIONS[self.random.randrange(0, 16)]
8686
)

0 commit comments

Comments
 (0)