Skip to content

Commit

Permalink
handle empty clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
kapoorlab committed Nov 3, 2023
1 parent 5aa98e7 commit d3b1ddd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/napatrackmater/Trackvector.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,15 @@ def unsupervised_clustering(
track_arrays_array.index(track_arrays)
]
shape_dynamic_cosine_distance = pdist(clusterable_track_array, metric=metric)
if (
np.isnan(shape_dynamic_cosine_distance).any()
or np.isinf(shape_dynamic_cosine_distance).any()
):
print(
"Cosine distance matrix contains NaN or infinite values. Returning an empty linkage matrix."
)
return

shape_dynamic_linkage_matrix = linkage(
shape_dynamic_cosine_distance, method=method
)
Expand Down
4 changes: 2 additions & 2 deletions src/napatrackmater/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = version = "4.4.1"
__version_tuple__ = version_tuple = (4, 4, 1)
__version__ = version = "4.4.2"
__version_tuple__ = version_tuple = (4, 4, 2)

0 comments on commit d3b1ddd

Please sign in to comment.