diff --git a/flee/flee.py b/flee/flee.py index b0f0a527..ae69a9a9 100644 --- a/flee/flee.py +++ b/flee/flee.py @@ -1212,20 +1212,6 @@ def set_conflict_intensity(self, name: str, conflict_intensity: float, change_mo self.add_conflict_zone(name, conflict_intensity, change_movechance) - @check_args_type - def pick_spawn_location(self): - """ - Summary - - !!! warning - this function is now deprecated as of ruleset 2.0. - Please use `pick_spawn_locations()` instead in your scripts - - Returns: - Location: Description - """ - return self.pick_spawn_locations(1)[0] - @check_args_type def pick_spawn_locations(self, number: int = 1) -> list: """ @@ -1243,8 +1229,10 @@ def pick_spawn_locations(self, number: int = 1) -> list: assert spawn_weight_total > 0 + wgt = self.spawn_weights / spawn_weight_total + return np.random.choice( - self.locations, number, p=self.spawn_weights / spawn_weight_total + self.locations, number, p=wgt ).tolist() diff --git a/flee/spawning.py b/flee/spawning.py index a5f796ce..8850950d 100644 --- a/flee/spawning.py +++ b/flee/spawning.py @@ -216,10 +216,10 @@ def spawn_daily_displaced(e, t, d): __refugee_debt = 0 #Insert refugee agents + locs = e.pick_spawn_locations(new_refs) for i in range(0, new_refs): - loc = e.pick_spawn_location() - attributes = draw_samples(e, loc) - e.addAgent(location=loc, attributes=attributes) # Parallelization is incorporated *inside* the addAgent function. + attributes = draw_samples(e, locs[i]) + e.addAgent(location=locs[i], attributes=attributes) # Parallelization is incorporated *inside* the addAgent function. return new_refs, __refugees_raw, __refugee_debt