Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wannesm committed Jun 4, 2019
1 parent 2843899 commit 95d9bcb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions dtaidistance/dtw.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,13 @@ def distances_array_to_matrix(dists, nb_series, block=None):

def distance_array_index(a, b, nb_series):
if a == b:
return 0
raise ValueError("Distance between the same series is not available.")
if a > b:
a, b = b, a
idx = 0
for r in range(a):
idx += nb_series - r - 1
idx += b
idx += b - a - 1
return idx


Expand Down
9 changes: 5 additions & 4 deletions tests/test_dtw.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def test_condensed_index1():
+-----------------------------+
"""
assert dtw.distance_array_index(3, 2, 5) == 9
assert dtw.distance_array_index(2, 3, 5) == 9
assert dtw.distance_array_index(1, 5, 5) == 8
assert dtw.distance_array_index(3, 2, 6) == 9
assert dtw.distance_array_index(2, 3, 6) == 9
assert dtw.distance_array_index(1, 5, 6) == 8


def test_distance1_a():
Expand Down Expand Up @@ -156,6 +156,7 @@ def test_distance_matrix_block():

if __name__ == "__main__":
# test_distance1_a()
test_distance_matrix2_e()
# test_distance_matrix2_e()
# run_distance_matrix_block(parallel=True, use_c=True, use_nogil=False)
# test_expected_length1()
test_condensed_index1()

0 comments on commit 95d9bcb

Please sign in to comment.