Skip to content

Commit 8e9d19d

Browse files
authored
start adding random state capability
1 parent cc5ddd4 commit 8e9d19d

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/eschr/tl/_clustering.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ def run_base_clustering(args_in):
269269
----------
270270
args_in : zip
271271
List containing each hyperparameter required for one round of
272-
clustering (k, la_res, metric, subsample_size) as well as a
273-
copy of the data as numpy.array or scipy.sparse.spmatrix
272+
clustering (k, la_res, metric, subsample_size) as well as the random seed,
273+
sparse boolean, and the path to the zarr data store.
274274
275275
Returns
276276
-------
@@ -283,8 +283,18 @@ def run_base_clustering(args_in):
283283
# LOAD DATA
284284
zarr_loc = args_in[0]
285285
hyperparams_ls = args_in[1]
286-
sparse = hyperparams_ls[3]
287-
286+
sparse = args_in[2]
287+
random_seed = args_in[3]
288+
process_id = args_in[4]
289+
290+
# Set random seeds for this process if provided
291+
if random_seed is not None:
292+
# Convert random_seed to a unique value for this process
293+
# This ensures different processes get different but deterministic seeds
294+
process_seed = random_seed + process_id
295+
random.seed(process_seed)
296+
np.random.seed(process_seed)
297+
288298
z1 = zarr.open(zarr_loc, mode="r")
289299

290300
if sparse:

0 commit comments

Comments
 (0)