@@ -28,8 +28,7 @@ def pairwise_phase_consistency(pha0, pha1=None, return_pairs=True, progress=None
2828 distance_avg : float
2929 Average pairwise circular distance index.
3030 distances : 2d array, optional
31- Pairwise circular distance indices. Only returned if ``return_pairs` is True. If
32- ``memory_gb`` is less than required array size, None will be returned.
31+ Pairwise circular distance indices. Only returned if ``return_pairs` is True.
3332
3433 Notes
3534 -----
@@ -63,15 +62,15 @@ def pairwise_phase_consistency(pha0, pha1=None, return_pairs=True, progress=None
6362
6463 else :
6564
66- n_combs = int ((len (pha0 ) * (len (pha0 ) + 1 )) / 2 )
65+ # Include all combinations
66+ n_combs = int (len (pha0 ) ** 2 )
6767
68- # Include self-combinations
69- iterable = enumerate (combinations_with_replacement (np .arange (len (pha0 )), 2 ))
68+ iterable = enumerate ((row , col ) for row in range (len (pha0 )) for col in range (len (pha1 )))
7069
7170 # Initialize variables
7271 if return_pairs :
7372 cumulative = None
74- distances = np .zeros ( n_combs )
73+ distances = np .ones (( len ( pha0 ), len ( pha0 )) )
7574 else :
7675 cumulative = 0
7776 distances = None
@@ -88,7 +87,7 @@ def pairwise_phase_consistency(pha0, pha1=None, return_pairs=True, progress=None
8887 # Compute distance indices
8988 for idx , pair in iterable :
9089
91- phi0 = pha0 [pair [0 ]]
90+ phi0 = pha0 [pair [0 ]]
9291
9392 if pha1 is None :
9493 phi1 = pha0 [pair [1 ]]
@@ -108,8 +107,11 @@ def pairwise_phase_consistency(pha0, pha1=None, return_pairs=True, progress=None
108107 # Pairwise circular distance index (PCDI)
109108 distance = (np .pi - 2 * abs_dist ) / np .pi
110109
111- if isinstance (distances , np .ndarray ):
112- distances [idx ] = distance
110+ if isinstance (distances , np .ndarray ) and pha1 is None :
111+ distances [pair [0 ], pair [1 ]] = distance
112+ distances [pair [1 ], pair [0 ]] = distance
113+ elif isinstance (distances , np .ndarray ) and pha1 is not None :
114+ distances [pair [0 ], pair [1 ]] = distance
113115 else :
114116 cumulative += distance
115117
0 commit comments