Skip to content

Commit 961014c

Browse files
committed
test(deep_causality_algorithms): removed dead code and unreachable errors to increased test coverage.
Signed-off-by: Marvin Hansen <[email protected]>
1 parent ebe8d67 commit 961014c

File tree

1 file changed

+7
-12
lines changed
  • deep_causality_algorithms/src/feature_selection/mrmr

1 file changed

+7
-12
lines changed

deep_causality_algorithms/src/feature_selection/mrmr/mrmr_algo.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)