Skip to content

Commit

Permalink
corrected for delta match
Browse files Browse the repository at this point in the history
  • Loading branch information
hfr1tz3 committed Jan 20, 2025
1 parent 74eb649 commit 393954c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion tests/test_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ def f(t):
)
dissimilarity_matrix[i, j] = 1 / (1 + time_array[i, j])
best_match_n1 = np.argmax(dissimilarity_matrix, axis=1)
best_match_n2 = np.argmax(dissimilarity_matrix, axis=0)
n2_match_matrix = np.zeros((ts.num_nodes, other.num_nodes))
for i, j in enumerate(best_match_n1):
n2_match_matrix[i, j] = dissimilarity_matrix[i, j]
best_match_n2 = np.argmax(n2_match_matrix, axis=0)
# find non-unque bins for nodes in n_2 then find max of node span from that bin.
best_match_n1_spans = np.zeros((ts.num_nodes,))
best_match_n2_spans = np.zeros((other.num_nodes,))
Expand Down
7 changes: 6 additions & 1 deletion tscompare/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,12 @@ def f(t):
# n2_match is finds the max match between nodes in N2 and their
# best match in N1 based on max-span (for tpr, inverse_dissimilarity)
best_n1_match = best_match_matrix.argmax(axis=1).A1
best_n2_match = best_match_matrix.argmax(axis=0).A1
n2_match_matrix = scipy.sparse.lil_matrix((ts.num_nodes, other.num_nodes))
n2_match_matrix[np.arange(ts.num_nodes), best_n1_match] = best_match_matrix.tocsr()[
np.arange(ts.num_nodes), best_n1_match
]
n2_match_matrix = n2_match_matrix.tocsr()
best_n2_match = n2_match_matrix.argmax(axis=0).A1
n2_match_mask = best_n1_match[best_n2_match] == np.arange(other.num_nodes)
best_match_n1_spans = shared_spans[np.arange(ts.num_nodes), best_n1_match].reshape(
-1
Expand Down

0 comments on commit 393954c

Please sign in to comment.