@@ -544,21 +544,30 @@ def compute_coef(idx_list):
544
544
if pvalue_n_permutations is not None and pvalue_n_permutations > 0 :
545
545
# compute CCC on permuted data
546
546
p_ccc_values = np .full (pvalue_n_permutations , np .nan , dtype = float )
547
+
548
+ # select the variable that generated more partitions as the one
549
+ # to permute
550
+ obj_parts_sel_i = obji_parts
551
+ obj_parts_sel_j = objj_parts
552
+ if (obji_parts [:, 0 ] >= 0 ).sum () > (objj_parts [:, 0 ] >= 0 ).sum ():
553
+ obj_parts_sel_i = objj_parts
554
+ obj_parts_sel_j = obji_parts
555
+
547
556
for idx_perm in range (pvalue_n_permutations ):
548
557
# generate a random permutation of the partitions of one
549
558
# variable/feature
550
559
perm_idx = np .random .permutation (n_objects )
551
- objj_parts_permuted = np .array (
560
+ obj_parts_sel_j_permuted = np .array (
552
561
[
553
- objj_parts [i , perm_idx ]
554
- for i in range (objj_parts .shape [0 ])
562
+ obj_parts_sel_j [i , perm_idx ]
563
+ for i in range (obj_parts_sel_j .shape [0 ])
555
564
]
556
565
)
557
566
558
567
# compute the CCC using the permuted partitions
559
568
p_comp_values = cdist_func (
560
- obji_parts ,
561
- objj_parts_permuted ,
569
+ obj_parts_sel_i ,
570
+ obj_parts_sel_j_permuted ,
562
571
)
563
572
p_max_flat_idx = p_comp_values .argmax ()
564
573
p_max_idx = unravel_index_2d (
0 commit comments