@@ -319,12 +319,10 @@ where
319319 relevance / redundancy
320320 } ;
321321
322- if !mrmr_score. is_finite ( ) {
323- return Err ( MrmrError :: FeatureScoreError ( format ! (
324- "mRMR score for feature {} is not finite: {}" ,
325- feature_idx, mrmr_score
326- ) ) ) ;
327- }
322+ // mRMR score is guaranteed to be finite here because non-finite cases (NaN or Infinity)
323+ // due to redundancy being zero are handled by the preceding if block.
324+ // Otherwise, the division of two finite numbers (relevance / redundancy) where
325+ // redundancy is non-zero will always yield a finite result.
328326
329327 if mrmr_score > max_mrmr_score {
330328 max_mrmr_score = mrmr_score;
@@ -334,12 +332,9 @@ where
334332 ( best_feature, max_mrmr_score)
335333 } ;
336334
337- if !best_feature_score. is_finite ( ) {
338- return Err ( MrmrError :: FeatureScoreError ( format ! (
339- "Best mRMR score for feature {} is not finite: {}" ,
340- best_feature, best_feature_score
341- ) ) ) ;
342- }
335+ // The best_feature_score is guaranteed to be finite here because all mrmr_score values
336+ // are checked for finiteness within the loop before updating max_mrmr_score.
337+ // If any mrmr_score was non-finite, an error would have been returned earlier.
343338 selected_features_with_scores. push ( ( best_feature, best_feature_score) ) ;
344339 all_features. remove ( & best_feature) ;
345340 }
0 commit comments