Skip to content

Commit cdcdfc8

Browse files
committed
fix: remove conflict markers by preferring OURS from 2c43b3f^1
1 parent 7c53eb8 commit cdcdfc8

File tree

12 files changed

+4
-1660
lines changed

12 files changed

+4
-1660
lines changed

docs/general/user-guide/1_classes.md

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,9 @@ You can access the underlying DataFrame where agents are stored with `self.df`.
2727

2828
## Model 🏗️
2929

30-
<<<<<<< HEAD
3130
To add your AgentSet to your Model, use the registry `self.sets` with `+=` or `add`.
3231

33-
Note: All agent sets live inside `AgentSetRegistry` (available as `model.sets`). Access sets through the registry, and access DataFrames from the set itself. For example: `self.sets["Preys"].df`
34-
=======
35-
36-
To add your AgentSet to your Model, you should also add it to the sets with `+=` or `add`.
37-
38-
NOTE: Model.sets are stored in a class which is entirely similar to AgentSet called AgentSetRegistry. The API of the two are the same. If you try accessing AgentSetRegistry.df, you will get a dictionary of `[AgentSet, DataFrame]`.
39-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
32+
Note: All agent sets live inside `AgentSetRegistry` (available as `model.sets`). Access sets through the registry, and access DataFrames from the set itself. For example: `self.sets["Preys"].df`.
4033

4134
Example:
4235

@@ -50,12 +43,8 @@ class EcosystemModel(Model):
5043
def step(self):
5144
self.sets.do("move")
5245
self.sets.do("hunt")
53-
<<<<<<< HEAD
5446
# Access specific sets via the registry
5547
self.sets["Preys"].do("reproduce")
56-
=======
57-
self.prey.do("reproduce")
58-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
5948
```
6049

6150
## Space: Grid 🌐
@@ -88,7 +77,6 @@ Example:
8877
class ExampleModel(Model):
8978
def __init__(self):
9079
super().__init__()
91-
<<<<<<< HEAD
9280
# Add the set to the registry
9381
self.sets.add(MoneyAgents(100, self))
9482
# Configure reporters: use the registry to locate sets; get df from the set
@@ -97,25 +85,15 @@ class ExampleModel(Model):
9785
model_reporters={
9886
"total_wealth": lambda m: m.sets["MoneyAgents"].df["wealth"].sum(),
9987
},
100-
=======
101-
self.sets = MoneyAgent(self)
102-
self.datacollector = DataCollector(
103-
model=self,
104-
model_reporters={"total_wealth": lambda m: lambda m: list(m.sets.df.values())[0]["wealth"].sum()},
105-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
10688
agent_reporters={"wealth": "wealth"},
10789
storage="csv",
10890
storage_uri="./data",
10991
trigger=lambda m: m.steps % 2 == 0,
11092
)
11193

11294
def step(self):
113-
<<<<<<< HEAD
11495
# Step all sets via the registry
11596
self.sets.do("step")
116-
=======
117-
self.sets.step()
118-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
11997
self.datacollector.conditional_collect()
12098
self.datacollector.flush()
12199
```

docs/general/user-guide/4_datacollector.ipynb

Lines changed: 3 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@
2626
},
2727
{
2828
"cell_type": "code",
29-
<<<<<<< HEAD
3029
"execution_count": 6,
31-
=======
32-
"execution_count": 18,
33-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
3430
"id": "9a63283cbaf04dbcab1f6479b197f3a8",
3531
"metadata": {
3632
"editable": true
@@ -67,27 +63,18 @@
6763
" │ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n",
6864
" │ i64 ┆ str ┆ i64 ┆ f64 ┆ i64 │\n",
6965
" ╞══════╪═════════════════════════════════╪═══════╪══════════════╪══════════╡\n",
70-
<<<<<<< HEAD
7166
" │ 2 ┆ 332212815818606584686857770936… ┆ 0 ┆ 1000.0 ┆ 1000 │\n",
7267
" │ 4 ┆ 332212815818606584686857770936… ┆ 0 ┆ 1000.0 ┆ 1000 │\n",
7368
" │ 6 ┆ 332212815818606584686857770936… ┆ 0 ┆ 1000.0 ┆ 1000 │\n",
7469
" │ 8 ┆ 332212815818606584686857770936… ┆ 0 ┆ 1000.0 ┆ 1000 │\n",
7570
" │ 10 ┆ 332212815818606584686857770936… ┆ 0 ┆ 1000.0 ┆ 1000 │\n",
76-
=======
77-
" │ 2 ┆ 162681765859364298619846106603… ┆ 0 ┆ 1000.0 ┆ 1000 │\n",
78-
" │ 4 ┆ 162681765859364298619846106603… ┆ 0 ┆ 1000.0 ┆ 1000 │\n",
79-
" │ 6 ┆ 162681765859364298619846106603… ┆ 0 ┆ 1000.0 ┆ 1000 │\n",
80-
" │ 8 ┆ 162681765859364298619846106603… ┆ 0 ┆ 1000.0 ┆ 1000 │\n",
81-
" │ 10 ┆ 162681765859364298619846106603… ┆ 0 ┆ 1000.0 ┆ 1000 │\n",
82-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
8371
" └──────┴─────────────────────────────────┴───────┴──────────────┴──────────┘,\n",
8472
" 'agent': shape: (5_000, 4)\n",
8573
" ┌────────────────────┬──────┬─────────────────────────────────┬───────┐\n",
8674
" │ wealth_MoneyAgents ┆ step ┆ seed ┆ batch │\n",
8775
" │ --- ┆ --- ┆ --- ┆ --- │\n",
8876
" │ f64 ┆ i32 ┆ str ┆ i32 │\n",
8977
" ╞════════════════════╪══════╪═════════════════════════════════╪═══════╡\n",
90-
<<<<<<< HEAD
9178
" │ 3.0 ┆ 2 ┆ 332212815818606584686857770936… ┆ 0 │\n",
9279
" │ 0.0 ┆ 2 ┆ 332212815818606584686857770936… ┆ 0 │\n",
9380
" │ 2.0 ┆ 2 ┆ 332212815818606584686857770936… ┆ 0 │\n",
@@ -103,23 +90,6 @@
10390
]
10491
},
10592
"execution_count": 7,
106-
=======
107-
" │ 0.0 ┆ 2 ┆ 162681765859364298619846106603… ┆ 0 │\n",
108-
" │ 3.0 ┆ 2 ┆ 162681765859364298619846106603… ┆ 0 │\n",
109-
" │ 1.0 ┆ 2 ┆ 162681765859364298619846106603… ┆ 0 │\n",
110-
" │ 3.0 ┆ 2 ┆ 162681765859364298619846106603… ┆ 0 │\n",
111-
" │ 6.0 ┆ 2 ┆ 162681765859364298619846106603… ┆ 0 │\n",
112-
" │ … ┆ … ┆ … ┆ … │\n",
113-
" │ 4.0 ┆ 10 ┆ 162681765859364298619846106603… ┆ 0 │\n",
114-
" │ 1.0 ┆ 10 ┆ 162681765859364298619846106603… ┆ 0 │\n",
115-
" │ 0.0 ┆ 10 ┆ 162681765859364298619846106603… ┆ 0 │\n",
116-
" │ 0.0 ┆ 10 ┆ 162681765859364298619846106603… ┆ 0 │\n",
117-
" │ 0.0 ┆ 10 ┆ 162681765859364298619846106603… ┆ 0 │\n",
118-
" └────────────────────┴──────┴─────────────────────────────────┴───────┘}"
119-
]
120-
},
121-
"execution_count": 19,
122-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
12393
"metadata": {},
12494
"output_type": "execute_result"
12595
}
@@ -150,13 +120,8 @@
150120
" self.dc = DataCollector(\n",
151121
" model=self,\n",
152122
" model_reporters={\n",
153-
<<<<<<< HEAD
154123
" \"total_wealth\": lambda m: m.sets[\"MoneyAgents\"].df[\"wealth\"].sum(),\n",
155124
" \"n_agents\": lambda m: len(m.sets[\"MoneyAgents\"]),\n",
156-
=======
157-
" \"total_wealth\": lambda m: list(m.sets.df.values())[0][\"wealth\"].sum(),\n",
158-
" \"n_agents\": lambda m: len(list(m.sets.df.values())[0]),\n",
159-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
160125
" },\n",
161126
" agent_reporters={\n",
162127
" \"wealth\": \"wealth\", # pull existing column\n",
@@ -210,7 +175,7 @@
210175
},
211176
{
212177
"cell_type": "code",
213-
"execution_count": 20,
178+
"execution_count": null,
214179
"id": "5f14f38c",
215180
"metadata": {},
216181
"outputs": [
@@ -220,11 +185,7 @@
220185
"[]"
221186
]
222187
},
223-
<<<<<<< HEAD
224188
"execution_count": 8,
225-
=======
226-
"execution_count": 20,
227-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
228189
"metadata": {},
229190
"output_type": "execute_result"
230191
}
@@ -237,13 +198,8 @@
237198
"model_csv.dc = DataCollector(\n",
238199
" model=model_csv,\n",
239200
" model_reporters={\n",
240-
<<<<<<< HEAD
241201
" \"total_wealth\": lambda m: m.sets[\"MoneyAgents\"].df[\"wealth\"].sum(),\n",
242202
" \"n_agents\": lambda m: len(m.sets[\"MoneyAgents\"]),\n",
243-
=======
244-
" \"total_wealth\": lambda m: list(m.sets.df.values())[0][\"wealth\"].sum(),\n",
245-
" \"n_agents\": lambda m: len(list(m.sets.df.values())[0]),\n",
246-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
247203
" },\n",
248204
" agent_reporters={\n",
249205
" \"wealth\": \"wealth\",\n",
@@ -270,7 +226,7 @@
270226
},
271227
{
272228
"cell_type": "code",
273-
"execution_count": 21,
229+
"execution_count": null,
274230
"id": "8763a12b2bbd4a93a75aff182afb95dc",
275231
"metadata": {
276232
"editable": true
@@ -282,11 +238,7 @@
282238
"[]"
283239
]
284240
},
285-
<<<<<<< HEAD
286241
"execution_count": 9,
287-
=======
288-
"execution_count": 21,
289-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
290242
"metadata": {},
291243
"output_type": "execute_result"
292244
}
@@ -297,13 +249,8 @@
297249
"model_parq.dc = DataCollector(\n",
298250
" model=model_parq,\n",
299251
" model_reporters={\n",
300-
<<<<<<< HEAD
301252
" \"total_wealth\": lambda m: m.sets[\"MoneyAgents\"].df[\"wealth\"].sum(),\n",
302253
" \"n_agents\": lambda m: len(m.sets[\"MoneyAgents\"]),\n",
303-
=======
304-
" \"total_wealth\": lambda m: list(m.sets.df.values())[0][\"wealth\"].sum(),\n",
305-
" \"n_agents\": lambda m: len(list(m.sets.df.values())[0]),\n",
306-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
307254
" },\n",
308255
" agent_reporters={\n",
309256
" \"wealth\": \"wealth\",\n",
@@ -332,7 +279,7 @@
332279
},
333280
{
334281
"cell_type": "code",
335-
"execution_count": 22,
282+
"execution_count": null,
336283
"id": "7cdc8c89c7104fffa095e18ddfef8986",
337284
"metadata": {
338285
"editable": true
@@ -343,13 +290,8 @@
343290
"model_s3.dc = DataCollector(\n",
344291
" model=model_s3,\n",
345292
" model_reporters={\n",
346-
<<<<<<< HEAD
347293
" \"total_wealth\": lambda m: m.sets[\"MoneyAgents\"].df[\"wealth\"].sum(),\n",
348294
" \"n_agents\": lambda m: len(m.sets[\"MoneyAgents\"]),\n",
349-
=======
350-
" \"total_wealth\": lambda m: list(m.sets.df.values())[0][\"wealth\"].sum(),\n",
351-
" \"n_agents\": lambda m: len(list(m.sets.df.values())[0]),\n",
352-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
353295
" },\n",
354296
" agent_reporters={\n",
355297
" \"wealth\": \"wealth\",\n",
@@ -377,11 +319,7 @@
377319
},
378320
{
379321
"cell_type": "code",
380-
<<<<<<< HEAD
381322
"execution_count": 11,
382-
=======
383-
"execution_count": 23,
384-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
385323
"id": "938c804e27f84196a10c8828c723f798",
386324
"metadata": {
387325
"editable": true
@@ -443,11 +381,7 @@
443381
},
444382
{
445383
"cell_type": "code",
446-
<<<<<<< HEAD
447384
"execution_count": 12,
448-
=======
449-
"execution_count": 24,
450-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
451385
"id": "59bbdb311c014d738909a11f9e486628",
452386
"metadata": {
453387
"editable": true
@@ -476,11 +410,7 @@
476410
},
477411
{
478412
"cell_type": "code",
479-
<<<<<<< HEAD
480413
"execution_count": 13,
481-
=======
482-
"execution_count": 25,
483-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
484414
"id": "8a65eabff63a45729fe45fb5ade58bdc",
485415
"metadata": {
486416
"editable": true
@@ -496,11 +426,7 @@
496426
" white-space: pre-wrap;\n",
497427
"}\n",
498428
"</style>\n",
499-
<<<<<<< HEAD
500429
"<small>shape: (5, 5)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>step</th><th>seed</th><th>batch</th><th>total_wealth</th><th>n_agents</th></tr><tr><td>i64</td><td>str</td><td>i64</td><td>f64</td><td>i64</td></tr></thead><tbody><tr><td>2</td><td>&quot;540832786058427425452319829502…</td><td>0</td><td>100.0</td><td>100</td></tr><tr><td>4</td><td>&quot;540832786058427425452319829502…</td><td>0</td><td>100.0</td><td>100</td></tr><tr><td>6</td><td>&quot;540832786058427425452319829502…</td><td>0</td><td>100.0</td><td>100</td></tr><tr><td>8</td><td>&quot;540832786058427425452319829502…</td><td>0</td><td>100.0</td><td>100</td></tr><tr><td>10</td><td>&quot;540832786058427425452319829502…</td><td>0</td><td>100.0</td><td>100</td></tr></tbody></table></div>"
501-
=======
502-
"<small>shape: (5, 5)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>step</th><th>seed</th><th>batch</th><th>total_wealth</th><th>n_agents</th></tr><tr><td>i64</td><td>str</td><td>i64</td><td>f64</td><td>i64</td></tr></thead><tbody><tr><td>2</td><td>&quot;732054881101029867447298951813…</td><td>0</td><td>100.0</td><td>100</td></tr><tr><td>4</td><td>&quot;732054881101029867447298951813…</td><td>0</td><td>100.0</td><td>100</td></tr><tr><td>6</td><td>&quot;732054881101029867447298951813…</td><td>0</td><td>100.0</td><td>100</td></tr><tr><td>8</td><td>&quot;732054881101029867447298951813…</td><td>0</td><td>100.0</td><td>100</td></tr><tr><td>10</td><td>&quot;732054881101029867447298951813…</td><td>0</td><td>100.0</td><td>100</td></tr></tbody></table></div>"
503-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
504430
],
505431
"text/plain": [
506432
"shape: (5, 5)\n",
@@ -509,7 +435,6 @@
509435
"│ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n",
510436
"│ i64 ┆ str ┆ i64 ┆ f64 ┆ i64 │\n",
511437
"╞══════╪═════════════════════════════════╪═══════╪══════════════╪══════════╡\n",
512-
<<<<<<< HEAD
513438
"│ 2 ┆ 540832786058427425452319829502… ┆ 0 ┆ 100.0 ┆ 100 │\n",
514439
"│ 4 ┆ 540832786058427425452319829502… ┆ 0 ┆ 100.0 ┆ 100 │\n",
515440
"│ 6 ┆ 540832786058427425452319829502… ┆ 0 ┆ 100.0 ┆ 100 │\n",
@@ -519,17 +444,6 @@
519444
]
520445
},
521446
"execution_count": 13,
522-
=======
523-
"│ 2 ┆ 732054881101029867447298951813… ┆ 0 ┆ 100.0 ┆ 100 │\n",
524-
"│ 4 ┆ 732054881101029867447298951813… ┆ 0 ┆ 100.0 ┆ 100 │\n",
525-
"│ 6 ┆ 732054881101029867447298951813… ┆ 0 ┆ 100.0 ┆ 100 │\n",
526-
"│ 8 ┆ 732054881101029867447298951813… ┆ 0 ┆ 100.0 ┆ 100 │\n",
527-
"│ 10 ┆ 732054881101029867447298951813… ┆ 0 ┆ 100.0 ┆ 100 │\n",
528-
"└──────┴─────────────────────────────────┴───────┴──────────────┴──────────┘"
529-
]
530-
},
531-
"execution_count": 25,
532-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
533447
"metadata": {},
534448
"output_type": "execute_result"
535449
}

examples/sugarscape_ig/ss_polars/model.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,19 @@ def __init__(
3333
sugar=sugar_grid.flatten(), max_sugar=sugar_grid.flatten()
3434
)
3535
self.space.set_cells(sugar_grid)
36-
<<<<<<< HEAD
3736
# Create and register the main agent set; keep its name for later lookups
3837
main_set = agent_type(self, n_agents, initial_sugar, metabolism, vision)
3938
self.sets += main_set
4039
self._main_set_name = main_set.name
41-
=======
42-
self.sets += agent_type(self, n_agents, initial_sugar, metabolism, vision)
43-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
4440
if initial_positions is not None:
4541
self.space.place_agents(self.sets, initial_positions)
4642
else:
4743
self.space.place_to_empty(self.sets)
4844

4945
def run_model(self, steps: int) -> list[int]:
5046
for _ in range(steps):
51-
<<<<<<< HEAD
5247
# Stop if the main agent set is empty
5348
if len(self.sets[self._main_set_name]) == 0: # type: ignore[index]
54-
=======
55-
if len(list(self.sets.df.values())[0]) == 0:
56-
>>>>>>> 51c54cd666d876a5debb1b7dd71556ee9c458956
5749
return
5850
empty_cells = self.space.empty_cells
5951
full_cells = self.space.full_cells

0 commit comments

Comments
 (0)