Skip to content

Commit f2ec533

Browse files
authored
Merge pull request #3490 from janezd/fix-spearman-for-scipy-1.2.0
Spearman distances: Return 0 when comparing a single row to itself
2 parents e5de908 + 81f8ac8 commit f2ec533

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Orange/distance/distance.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,9 @@ class SpearmanModel(CorrelationDistanceModel):
433433
def compute_correlation(self, x1, x2):
434434
if x2 is None:
435435
n1 = x1.shape[1 - self.axis]
436-
if n1 == 2:
436+
if n1 == 1:
437+
rho = 1.0
438+
elif n1 == 2:
437439
# Special case to properly fill degenerate self correlations
438440
# (nan, inf on the diagonals)
439441
rho = stats.spearmanr(x1, x1, axis=self.axis)[0]

0 commit comments

Comments
 (0)