Skip to content

Commit

Permalink
Clear invalidated medoid cache on packing (#373)
Browse files Browse the repository at this point in the history
Packing the indices of a ClusterGenerator shifts the meaning of the integers
in its cache, invalidating it.
I suppose they could be updated in the cache, but that'd be a complex piece of
code a clustering implementation which is already too complex for its own good.
Instead, clear the cache when packing.

This should happen a neglible amount of times compared to how often we already
clear the cache.
  • Loading branch information
jakobnissen authored Nov 28, 2024
1 parent 21bdcdd commit 6c97ece
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions vamb/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ def pack(self):
self.lengths = self.lengths[self.kept_mask]
self.kept_mask.resize_(len(self.matrix))
self.kept_mask[:] = 1
# The medoid cache is invalidated when the indices shifts
self.medoid_cache.clear()

def pack_order(self):
"Remove all used points from self.order"
Expand Down

0 comments on commit 6c97ece

Please sign in to comment.