Skip to content

Commit

Permalink
🚸 Replace Inf values in output from compute_measures with NA; this re…
Browse files Browse the repository at this point in the history
…turns more evaluation measures.
  • Loading branch information
adrian-gadient committed Jan 14, 2025
1 parent 02ff60b commit 1e143ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions R/compute_measures.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ compute_measures <- function(combined, weight_groups = NULL) {
)
}

# Replace Inf values with NA
df <- df |>
dplyr::mutate(dplyr::across(everything(), ~replace(., is.infinite(.), NA)))

# Feedback when there are Inf values in output ----
if (any(sapply(df, is.infinite))) {
cli::cli_text(cli::col_red("Warning message:"))
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/_snaps/compute_measures.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
-1.2422360248447204, 1.8518518518518516, 1.6666666666666667,
15.66265060240964, 1.694915254237288, 8.88888888888889, 6.451612903225806,
17.857142857142858, -3.4482758620689653, 0, 6.666666666666667, 50,
-16.666666666666664, 0, -50, 0, Inf, 100, 4.990019960079841,
-16.666666666666664, 0, -50, 0, NA, 100, 4.990019960079841,
3.1746031746031744, -2.2426095820591234, 1.778242677824268, 0,
2.456499488229273, 0.3980099502487562, 0.20429009193054137,
2.7439024390243905, 7.586206896551724, 1.3888888888888888, 5.616740088105727,
Expand Down Expand Up @@ -299,7 +299,7 @@
0.6688963210702341, 3.862660944206009, 3.211009174311927, 1.2422360248447204,
1.8518518518518516, 1.6666666666666667, 15.66265060240964, 1.694915254237288,
8.88888888888889, 6.451612903225806, 17.857142857142858, 3.4482758620689653,
0, 6.666666666666667, 50, 16.666666666666664, 0, 50, 0, Inf, 100,
0, 6.666666666666667, 50, 16.666666666666664, 0, 50, 0, NA, 100,
4.990019960079841, 3.1746031746031744, 2.2426095820591234, 1.778242677824268,
0, 2.456499488229273, 0.3980099502487562, 0.20429009193054137,
2.7439024390243905, 7.586206896551724, 1.3888888888888888, 5.616740088105727,
Expand Down Expand Up @@ -514,7 +514,7 @@
-1.2422360248447204, 1.8518518518518516, 1.6666666666666667,
15.66265060240964, 1.694915254237288, 8.88888888888889, 6.451612903225806,
17.857142857142858, -3.4482758620689653, 0, 6.666666666666667, 50,
-16.666666666666664, 0, -50, 0, Inf, 100, 4.990019960079841,
-16.666666666666664, 0, -50, 0, NA, 100, 4.990019960079841,
3.1746031746031744, -2.2426095820591234, 1.778242677824268, 0,
2.456499488229273, 0.3980099502487562, 0.20429009193054137,
2.7439024390243905, 7.586206896551724, 1.3888888888888888, 5.616740088105727,
Expand Down Expand Up @@ -629,7 +629,7 @@
0.6688963210702341, 3.862660944206009, 3.211009174311927, 1.2422360248447204,
1.8518518518518516, 1.6666666666666667, 15.66265060240964, 1.694915254237288,
8.88888888888889, 6.451612903225806, 17.857142857142858, 3.4482758620689653,
0, 6.666666666666667, 50, 16.666666666666664, 0, 50, 0, Inf, 100,
0, 6.666666666666667, 50, 16.666666666666664, 0, 50, 0, NA, 100,
4.990019960079841, 3.1746031746031744, 2.2426095820591234, 1.778242677824268,
0, 2.456499488229273, 0.3980099502487562, 0.20429009193054137,
2.7439024390243905, 7.586206896551724, 1.3888888888888888, 5.616740088105727,
Expand Down Expand Up @@ -924,7 +924,7 @@
0.0037685753792148506, 0.0003638561602850366, 0.0012038456464971293,
0.000734329319371533, 0.001646597388825861, 0.00028318636126789586, 0,
0.00036499575452306584, 0.0011526181721781027, 0.0002881545430445256, 0,
0.0006483477218501827, 0, Inf, 0.0005763090860890514, 0.014357400759977988,
0.0006483477218501827, 0, NA, 0.0005763090860890514, 0.014357400759977988,
0.009481656630655581, 0.006662509016652325, 0.005149707497819791, 0,
0.007195310370638943, 0.0011772761728764398, 0.0005930862147443505,
0.008230853395683416, 0.02087629982539822, 0.003974131406155749,
Expand Down

0 comments on commit 1e143ca

Please sign in to comment.