Skip to content

Commit 9ee3374

Browse files
committed
ccc: fix problem of random permutations across multiple processes
1 parent 57f4916 commit 9ee3374

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libs/ccc/coef/impl.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,17 @@ def compute_ccc_perms(params) -> NDArray[float]:
385385
Returns:
386386
The CCC coefficient values using the permuted partitions of one of the features.
387387
"""
388+
# since this function can be parallelized across different processes, make sure
389+
# the random number generator is initialized with a different seed for each process
390+
rng = np.random.default_rng()
391+
388392
_, obj_parts_i, obj_parts_j, n_perms = params
389393

390394
n_objects = obj_parts_i.shape[1]
391395
ccc_perm_values = np.full(n_perms, np.nan, dtype=float)
392396

393397
for idx in range(n_perms):
394-
perm_idx = np.random.permutation(n_objects)
398+
perm_idx = rng.permutation(n_objects)
395399

396400
# generate a random permutation of the partitions of one
397401
# variable/feature

0 commit comments

Comments
 (0)