Skip to content

Commit

Permalink
ok, we format floating point numbers to strings for comparison
Browse files Browse the repository at this point in the history
because signif alone didn't work well on Linux platforms
  • Loading branch information
mrcaseb committed Dec 22, 2022
1 parent dc1d776 commit 59f958d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions tests/testthat/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ load_test_pbp <- function(pbp = pbp_cache, dir = test_dir){

# model output differs across machines so we round to 4 significant digits
# to prevent failing tests
pbp_data <- build_nflfastR_pbp(game_ids, dir = dir, games = g) %>%
# we gotta round floating point numbers because of different model output
# across platforms
round_double_to_digits()
pbp_data <- build_nflfastR_pbp(game_ids, dir = dir, games = g)
if(!is.null(dir)) saveRDS(pbp_data, pbp)
pbp_data
}
Expand Down Expand Up @@ -58,5 +55,5 @@ strip_nflverse_attributes <- function(df){
}

round_double_to_digits <- function(df, digits = 4){
dplyr::mutate_if(df, is.double, signif, digits = digits)
dplyr::mutate_if(df, is.double, formatC, digits = digits, format = "fg")
}

0 comments on commit 59f958d

Please sign in to comment.