File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -485,8 +485,6 @@ def assign_closest_facility_level(self):
485485 nearest-neighbor matching, restricted to facilities within each individual's district.
486486 """
487487 import hashlib
488- import secrets
489- import time
490488
491489 worldpop_gdf = self .parameters ["worldpop_gdf" ].copy ()
492490 worldpop_gdf ["Z_prop" ] = pd .to_numeric (worldpop_gdf ["Z_prop" ], errors = "coerce" )
@@ -518,9 +516,12 @@ def assign_closest_facility_level(self):
518516 "Nkhatabay" : "Nkhata Bay" ,
519517 }
520518
521- # Worldpop-weighted coordinate assignment
522- run_seed = secrets .token_bytes (16 ) + int (time .time () * 1e9 ).to_bytes (8 , "big" )
523- unique_districts = df ["district_of_residence" ].unique ()
519+ # Worldpop-weighted coordinate assignment.
520+ # FIX: derive run_seed from the module RNG (not secrets/time) so results are
521+ # reproducible across runs that share the same random seed.
522+ run_seed = self .rng .randint (0 , 2 ** 31 - 1 ).to_bytes (4 , "big" )
523+ # FIX: sort districts so iteration order is deterministic regardless of PYTHONHASHSEED.
524+ unique_districts = sorted (df ["district_of_residence" ].unique ())
524525
525526 district_to_coords = {}
526527 for district in unique_districts :
You can’t perform that action at this time.
0 commit comments