File tree Expand file tree Collapse file tree 3 files changed +5
-0
lines changed
Expand file tree Collapse file tree 3 files changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ impl Kmeans {
9494 if adjust_weight {
9595 let remapped = colors[ matched as usize ] ;
9696 let ( _, new_diff) = n. search ( & f_pixel ( px. 0 + px. 0 - remapped. 0 ) , matched) ;
97+ debug_assert ! ( new_diff. is_finite( ) ) ;
9798 diff = new_diff;
9899 item. adjusted_weight = 2.0f32 . mul_add ( item. adjusted_weight , item. perceptual_weight ) * ( 0.5 + diff) ;
99100 }
Original file line number Diff line number Diff line change @@ -311,13 +311,15 @@ impl Ord for OrdFloat<f64> {
311311}
312312
313313impl OrdFloat < f32 > {
314+ #[ cfg_attr( debug_assertions, track_caller) ]
314315 pub fn new ( v : f32 ) -> Self {
315316 debug_assert ! ( v. is_finite( ) ) ;
316317 Self ( v)
317318 }
318319}
319320
320321impl OrdFloat < f64 > {
322+ #[ cfg_attr( debug_assertions, track_caller) ]
321323 pub fn new64 ( v : f64 ) -> Self {
322324 debug_assert ! ( v. is_finite( ) ) ;
323325 Self ( v)
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ impl<'hist> MBox<'hist> {
4242
4343 fn new_inner ( hist : & ' hist mut [ HistItem ] , adjusted_weight_sum : f64 , avg_color : f_pixel ) -> Self {
4444 let ( variance, max_error) = Self :: box_stats ( hist, avg_color) ;
45+ debug_assert ! ( adjusted_weight_sum. is_finite( ) ) ;
4546 Self {
4647 variance,
4748 max_error,
@@ -311,6 +312,7 @@ fn weighed_average_color(hist: &[HistItem]) -> f_pixel {
311312 sum += c. adjusted_weight ;
312313 t. 0 += c. color . 0 * c. adjusted_weight ;
313314 }
315+ debug_assert ! ( sum. is_finite( ) ) ;
314316 if sum != 0. {
315317 t. 0 /= sum;
316318 }
You can’t perform that action at this time.
0 commit comments