INNER CODE UNIT · Python
x_diffs
linzhiqiu/t2v_metrics · dataset.py:45
x_diffs = x1 - x2
# Introduce ties into x by setting the diffs to 0 if they are <= epsilon
x_is_tie = np.abs(x_diffs) <= epsilon
x_diffs[x_is_tie] = 0.0
y1, y2 = np.meshgrid(y, y.T)
y_diffs = y1 - y2
y_is_tie = y_diffs == 0.0
n = len(y)
num_pairs = int(scipy.special.comb(n, 2))
# All of the counts are divided by 2 because each pair is double counted. The
# double counted data will always be an even number, so dividing by 2 will
# be an integer.
con = int(
((x_diffs > 0) & (y_diffs > 0) | (x_diffs < 0) & (y_diffs < 0)).sum() / 2
)
t_x = int((x_is_tie & ~y_is_tie).sum() / 2)