// >>>
variants_total = min(variants_total, self.MAX_VARIANTS_TOTAL)
for path in rand.sample(range(variants_total),
self.TOP_VARIANTS):
yield self._decode_path(path, matrix)
// Less than TOP_VARIANTS elems in matrix
After Change
variants_total = min(variants_total, self.MAX_VARIANTS_TOTAL)
for _ in xrange(self.TOP_VARIANTS):
path = rand.randint(0, variants_total)
yield self._decode_path(path, matrix)
// Less than TOP_VARIANTS elems in matrix
else: