Skip to content

Commit 642697e

Browse files
authored
gis: Remove more unique_ids (#205)
Remove more unique_ids from the Agents init in the GIS models.
1 parent a3f20ae commit 642697e

File tree

6 files changed

+4
-11
lines changed

6 files changed

+4
-11
lines changed

gis/agents_and_networks/src/model/model.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import uuid
21
from functools import partial
32
from pathlib import Path
43

@@ -137,7 +136,6 @@ def _create_commuters(self) -> None:
137136
random_home = self.space.get_random_home()
138137
random_work = self.space.get_random_work()
139138
commuter = Commuter(
140-
unique_id=uuid.uuid4().int,
141139
model=self,
142140
geometry=Point(random_home.centroid),
143141
crs=self.space.crs,

gis/geo_schelling/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def __init__(self, density=0.6, minority_pc=0.2, export_data=False):
9090
data_path = script_directory / "data/nuts_rg_60M_2013_lvl_2.geojson"
9191
agents_gdf = gpd.read_file(data_path)
9292
agents_gdf = get_largest_connected_components(agents_gdf)
93-
agents = ac.from_GeoDataFrame(agents_gdf, unique_id="index")
93+
agents = ac.from_GeoDataFrame(agents_gdf)
9494
self.space.add_agents(agents)
9595

9696
# Set up agents

gis/geo_schelling_points/geo_schelling_points/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self, red_percentage=0.5, similarity_threshold=0.5):
2727
# Set up the grid with patches for every NUTS region
2828
ac = mg.AgentCreator(RegionAgent, model=self)
2929
data_path = script_directory / "../data/nuts_rg_60M_2013_lvl_2.geojson"
30-
regions = ac.from_file(data_path, unique_id="NUTS_ID")
30+
regions = ac.from_file(data_path)
3131
self.space.add_regions(regions)
3232

3333
for region in regions:

gis/geo_sir/model.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ def __init__(
5454
# Set up the Neighbourhood patches for every region in file
5555
# (add to schedule later)
5656
ac = mg.AgentCreator(NeighbourhoodAgent, model=self)
57-
neighbourhood_agents = ac.from_file(
58-
self.geojson_regions, unique_id=self.unique_id
59-
)
57+
neighbourhood_agents = ac.from_file(self.geojson_regions)
6058
self.space.add_agents(neighbourhood_agents)
6159

6260
# Generate PersonAgent population

gis/population/population/space.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import gzip
4-
import uuid
54

65
import geopandas as gpd
76
import mesa
@@ -47,7 +46,7 @@ def load_data(self, population_gzip_file, lake_zip_file, world_zip_file, model):
4746
raster_layer.total_bounds = world_size.total_bounds
4847
self.add_layer(raster_layer)
4948
self.lake = gpd.GeoDataFrame.from_file(lake_zip_file).geometry[0]
50-
self.add_agents(GeoAgent(uuid.uuid4().int, model, self.lake, self.crs))
49+
self.add_agents(GeoAgent(model, self.lake, self.crs))
5150

5251
@property
5352
def population_layer(self):

gis/rainfall/rainfall/model.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import uuid
21
from pathlib import Path
32

43
import mesa
@@ -98,7 +97,6 @@ def step(self):
9897
random_x = np.random.randint(0, self.space.raster_layer.width)
9998
random_y = np.random.randint(0, self.space.raster_layer.height)
10099
raindrop = RaindropAgent(
101-
unique_id=uuid.uuid4().int,
102100
model=self,
103101
pos=(random_x, random_y),
104102
)

0 commit comments

Comments
 (0)