Skip to content

Commit

Permalink
Misc edits
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivordir committed May 19, 2023
1 parent cb9b1ea commit 6e3213c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion okolors/src/kmeans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ fn kmeans_plus_plus<D: ColorDifference>(
*weight = f32::min(*weight, D::squared_distance(color, centroid));
}

match WeightedIndex::new(weights.iter().copied()) {
match WeightedIndex::new(&*weights) {
Ok(sampler) => centroids.push(colors[sampler.sample(rng)]),
Err(AllWeightsZero) => return, // all points exactly match a centroid
Err(InvalidWeight | NoItem | TooMany) => {
Expand Down
2 changes: 1 addition & 1 deletion okolors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ mod tests {

fn test_colors() -> Vec<Srgb<u8>> {
let range = (0..u8::MAX).step_by(16);
let mut colors = Vec::new();
let mut colors = Vec::with_capacity(range.len().pow(3));

for r in range.clone() {
for g in range.clone() {
Expand Down

0 comments on commit 6e3213c

Please sign in to comment.