@@ -63,15 +63,15 @@ def pairwise_phase_consistency(pha0, pha1=None, return_pairs=True, progress=None
6363
6464 else :
6565
66- n_combs = int ((len (pha0 ) * (len (pha0 ) + 1 )) / 2 )
66+ # Include all combinations
67+ n_combs = int (len (pha0 ) ** 2 )
6768
68- # Include self-combinations
69- iterable = enumerate (combinations_with_replacement (np .arange (len (pha0 )), 2 ))
69+ iterable = enumerate ((row , col ) for row in range (len (pha0 )) for col in range (len (pha1 )))
7070
7171 # Initialize variables
7272 if return_pairs :
7373 cumulative = None
74- distances = np .zeros ( n_combs )
74+ distances = np .ones (( len ( pha0 ), len ( pha0 )) )
7575 else :
7676 cumulative = 0
7777 distances = None
@@ -88,7 +88,7 @@ def pairwise_phase_consistency(pha0, pha1=None, return_pairs=True, progress=None
8888 # Compute distance indices
8989 for idx , pair in iterable :
9090
91- phi0 = pha0 [pair [0 ]]
91+ phi0 = pha0 [pair [0 ]]
9292
9393 if pha1 is None :
9494 phi1 = pha0 [pair [1 ]]
@@ -108,8 +108,11 @@ def pairwise_phase_consistency(pha0, pha1=None, return_pairs=True, progress=None
108108 # Pairwise circular distance index (PCDI)
109109 distance = (np .pi - 2 * abs_dist ) / np .pi
110110
111- if isinstance (distances , np .ndarray ):
112- distances [idx ] = distance
111+ if isinstance (distances , np .ndarray ) and pha1 is None :
112+ distances [pair [0 ], pair [1 ]] = distance
113+ distances [pair [1 ], pair [0 ]] = distance
114+ elif isinstance (distances , np .ndarray ) and pha1 is not None :
115+ distances [pair [0 ], pair [1 ]] = distance
113116 else :
114117 cumulative += distance
115118
0 commit comments