Skip to content

Commit 1fca354

Browse files
authored
Prevent NaN on tpr (#150)
1 parent 10b82b5 commit 1fca354

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

plugin/src/main/java/org/owasp/benchmarkutils/score/BenchmarkScore.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,8 @@ private static ToolResults calculateMetrics(Map<String, TP_FN_TN_FP_Counts> resu
620620
// c.tp & c.fp can both be zero, creating a precision of NaN. So set to 0.0.
621621
if (Double.isNaN(precision)) precision = 0.0;
622622
double tpr = (double) c.tp / (double) (c.tp + c.fn);
623+
// c.tp & c.fn can both be zero, creating an tpr of NaN. So set to 0.0.
624+
if (Double.isNaN(tpr)) tpr = 0.0;
623625
double fpr = (double) c.fp / (double) (c.fp + c.tn);
624626
// c.fp & c.tn can both be zero, creating an fpr of NaN. So set to 0.0.
625627
if (Double.isNaN(fpr)) fpr = 0.0;

0 commit comments

Comments
 (0)