Aggregated warnings
A warning was thrown by these expectations.
Location | Test | Description | Expectation | Message |
---|---|---|---|---|
test-fm_fit_model.R#3 | (code run outside of test_that() ) |
test_that(“fm_fit_model works”, { # You can test your model for small datas or big datas. You must run the tests locally with FISHMAP_UPDATE_OUTPUTS env at TRUE to store the rds file. test_resolution <- Sys.getenv(“FISHMAP_TEST_RESOLUTION”, unset = “small”) if(test_resolution == “small”){ fm_data_inputs <- readr::read_rds( system.file(“examples”, “part1_output_small.rds”, package = “FishMap”) ) }else if (test_resolution == “big”) { ## TODO use correct params for line below fm_data_inputs <- readr::read_rds( file.path(“data”, “part1_output_big.rds”) ) } # run part2 withr::with_seed(1234,{ fm_model_results <- fm_fit_model(fm_data_inputs = fm_data_inputs, SE = 1, data_source = 1, data_obs = 2, samp_process = 0, b_constraint = 2, cov_samp_process = 0, biomass_temporal = 1, sampling_temporal = 0, lf_link = 0, ref_data = “com”, EM = “est_b”, month_ref = 1, compute_sd = FALSE) }) # Update expected outputs here if (Sys.getenv(“FISHMAP_UPDATE_TEST_OUTPUTS”) == “TRUE”) { # save output depending if we are in flat or in test output_inst_dir <- here::here(“inst”, “examples”) if (test_resolution == “small”) { # save all output except sdreport (large file) readr::write_rds(x = fm_model_results[names(fm_model_results) != “SD”], file = file.path(output_inst_dir, paste0(“part2_output_”, test_resolution , “.rds”))) }else if (test_resolution == “big”) { ## TODO what we need to check readr::write_rds(x = fm_model_results[names(fm_model_results) != “SD”], file = file.path(“data”, paste0(“part2_output_”, test_resolution , “.rds”))) } } # check output is saved as rds if (Sys.getenv(“FISHMAP_UPDATE_TEST_OUTPUTS”) == “TRUE”) { output_inst_dir <- here::here(“inst”, “examples”) if (test_resolution == “small”) { #’ @description Test to check if we can save output small expect_true(file.exists(file.path(output_inst_dir, paste0(“part2_output_”, test_resolution , “.rds”)))) }else if (test_resolution == “big”) { #’ @description Test to check if we can save output big expect_true(file.exists(file.path(“data”, paste0(“part2_output_”, test_resolution , “.rds”)))) } } # Check results of model #’ @description Testing the result of fm_fit_model is a list expect_type(object = fm_model_results, “list”) #’ @description Testing names of the list return by fm_fit_model expect_named( object = fm_model_results, expected = c( “time.step_df”, “loc_x” , “report” , “samp_process”, “converge”, “SD”) ) #’ @description Testing types inside the list return by fm_fit_model expect_s3_class(fm_model_results\(time.step_df, "data.frame") expect_s3_class(fm_model_results\)loc_x, “data.frame”) expect_type(fm_model_results\(report, "list") expect_type(fm_model_results\)samp_process, “double”) expect_type(fm_model_results\(converge, "integer") # expect_s3_class(fm_model_results\)SD, “sdreport”) # Testing for small model (without sd report) fm_model_results <- fm_model_results[names(fm_model_results) != “SD”] if(test_resolution == “small”){ expected_outputs <- readr::read_rds( system.file( “examples”, paste0(“part2_output_”, test_resolution , “.rds”), package = “FishMap”) ) }else if(test_resolution == “big”){ expected_outputs <- readr::read_rds( file.path(“data”, paste0(“part2_output_”, test_resolution , “.rds”)) ) } # sort list and data frame elements to avoid order discrepancies resort_all <- function(x) { x <- x[sort(names(x))] result <- lapply(x, function(x) { if (inherits(x, c(“data.frame”, ‘list’))) { x[sort(names(x))] } else{ x } }) result } resorted_result <- resort_all(fm_model_results) resorted_expected <- resort_all(expected_outputs) # remove name attributes (likely generated by a specific version of {sf}) attr(resorted_result\(loc_x\)long, which = “names”) <- NULL attr(resorted_result\(loc_x\)lati, which = “names”) <- NULL attr(resorted_expected\(loc_x\)long, which = “names”) <- NULL attr(resorted_expected\(loc_x\)lati, which = “names”) <- NULL #’ @description Testing that the result of fm_fit_model is stable expect_equal( object = resorted_result, expected = resorted_expected, tolerance = 1e-4 ) # Testing fm_fit_model() runs for other parameters set #‘@descripton Testing if fm_fit_model work with a second parameter set result_fit_model <- try(fm_fit_model(fm_data_inputs = fm_data_inputs, SE = 1, data_source = 1, data_obs = 2, samp_process = 0, b_constraint = 2, cov_samp_process = 0, biomass_temporal = 0, #changed sampling_temporal = 1, # changed lf_link = 1, # changed ref_data = “sci”, # changed EM = “fix_b”, # changed month_ref = 1, compute_sd = FALSE), silent = TRUE) expect_true( !inherits(result_fit_model, “try-error”), label = “fm_fit_model generates a error when running with second parameter set” ) #’@descripton Testing if fm_fit_model work with a third parameter set result_fit_model <- try(fm_fit_model(fm_data_inputs = fm_data_inputs, SE = 1, data_source = 3, # changed data_obs = 2, samp_process = 0, b_constraint = 2, cov_samp_process = 0, biomass_temporal = 1, sampling_temporal = 0, lf_link = 0, ref_data = “com”, EM = “est_b”, month_ref = 1, compute_sd = FALSE), silent = TRUE) expect_true( !inherits(result_fit_model, “try-error”), label = “fm_fit_model generates a error when running with third parameter set” ) }) |
[ |
|
test-fm_fit_model.R#80 | fm_fit_model works | Testing the result of fm_fit_model is a list |
expect_type(object = fm_model_results, “list”) | [ |
test-fm_fit_model.R#83 | fm_fit_model works | Testing names of the list return by fm_fit_model |
expect_named( object = fm_model_results, expected = c( “time.step_df”, “loc_x” , “report” , “samp_process”, “converge”, “SD”) ) | [ |
test-fm_fit_model.R#96 | fm_fit_model works | Testing types inside the list return by fm_fit_model |
expect_s3_class(fm_model_results\(time.step_df, "data.frame") |[<text>:153] @descripton is not a known tag | |test-fm_fit_model.R#97 |fm_fit_model works |Testing types inside the list return by `fm_fit_model` |expect_s3_class(fm_model_results\)loc_x, “data.frame”) | [ |
test-fm_fit_model.R#98 | fm_fit_model works | expect_type(fm_model_results\(report, "list") |[<text>:153] @descripton is not a known tag | |test-fm_fit_model.R#99 |fm_fit_model works | |expect_type(fm_model_results\)samp_process, “double”) | [ |
|
test-fm_fit_model.R#100 | fm_fit_model works | expect_type(fm_model_results$converge, “integer”) | [ |
|
test-fm_fit_model.R#146 | fm_fit_model works | Testing that the result of fm_fit_model is stable |
expect_equal( object = resorted_result, expected = resorted_expected, tolerance = 1e-4 ) | [ |
test-fm_fit_model.R#154 | fm_fit_model works | result_fit_model <- try(fm_fit_model(fm_data_inputs = fm_data_inputs, SE = 1, data_source = 1, data_obs = 2, samp_process = 0, b_constraint = 2, cov_samp_process = 0, biomass_temporal = 0, #changed sampling_temporal = 1, # changed lf_link = 1, # changed ref_data = “sci”, # changed EM = “fix_b”, # changed month_ref = 1, compute_sd = FALSE), silent = TRUE) | NA/NaN function evaluation | |
test-fm_fit_model.R#170 | fm_fit_model works | expect_true( !inherits(result_fit_model, “try-error”), label = “fm_fit_model generates a error when running with second parameter set” ) |
[ |
|
test-fm_fit_model.R#192 | fm_fit_model works | expect_true( !inherits(result_fit_model, “try-error”), label = “fm_fit_model generates a error when running with third parameter set” ) |
[ |
|
test-main-r-part3-generate-output-graphs.R#3 | (code run outside of test_that() ) |
test_that(“Main functions work together”, { # Set up params for the model # use samp_process = 1 in model fit # use month_start = 10 and month_end = 12 # these parameters allow eta plot generation # run part1 survey_data_file <- system.file(“original_data”, “Solea_solea”, “survey_data.Rds”, package = “FishMap” ) survey_data <- readr::read_rds(file = survey_data_file) vmslogbook_data_file <- system.file(“original_data”, “Solea_solea”, “vmslogbook_data.Rds”, package = “FishMap” ) vmslogbook_data <- readr::read_rds(file = vmslogbook_data_file) study_domain_file <- system.file(“original_data”, “Solea_solea”, “study_domain.Rds”, package = “FishMap” ) study_domain <- readr::read_rds(file = study_domain_file) fm_data_inputs <- fm_load_data(species = “Solea_solea”, fleet = c(“OTB_DEF_>=70_0”,“OTB_CEP_>=70_0”,“OTT_DEF_>=70_0”), fitted_data = “biomass”, survey_data = survey_data, vmslogbook_data = vmslogbook_data, study_domain = study_domain, year_start = 2018, year_end = 2018, month_start = 10, month_end = 12, time_step = “Month”, k = 0.25, grid_xmin = -6, grid_xmax = 0, grid_ymin = 42, grid_ymax = 48) #‘@description Testing that fm_data_inputs return a named list for the next function test_list <- is.list(fm_data_inputs) test_name <- length(names(fm_data_inputs)) != 0 expect_true(test_list & test_name) #’@descripton Testing if fm_fit_model always work result_fit_model <- try( fm_fit_model(fm_data_inputs = fm_data_inputs, SE = 1, data_source = 1, data_obs = 2, samp_process = 1, b_constraint = 2, cov_samp_process = 0, biomass_temporal = 1, sampling_temporal = 0, lf_link = 0, ref_data = “com”, EM = “est_b”, month_ref = 1), silent = TRUE) expect_true( !inherits(result_fit_model, “try-error”), label = “fm_fit_model generate a error. Please check the core function or the returned objet of fm_load_data . Running function” ) #‘@descripton Testing if fm_fit_model always work result_graph <- try(fm_generate_graphs(result_fit_model), silent = TRUE) expect_true( !inherits(result_graph, “try-error”), label = “fm_generate_graphs generate a error. Please check the core function or the returned objet of fm_fit_model . Running function” ) #’@description testing output of fm_generate_graphs expect_type(result_graph, “list”) expect_s3_class(result_graph[[“pred_plot”]], “ggplot”) expect_s3_class(result_graph[[“eta_plot”]], “ggplot”)}) |
[ |
|
test-main-r-part3-generate-output-graphs.R#57 | Main functions work together | expect_true(test_list & test_name) | [ |
|
test-main-r-part3-generate-output-graphs.R#76 | Main functions work together | expect_true( !inherits(result_fit_model, “try-error”), label = “fm_fit_model generate a error. Please check the core function or the returned objet of fm_load_data . Running function” ) |
[ |
|
test-main-r-part3-generate-output-graphs.R#85 | Main functions work together | expect_true( !inherits(result_graph, “try-error”), label = “fm_generate_graphs generate a error. Please check the core function or the returned objet of fm_fit_model . Running function” ) |
[ |
|
test-main-r-part3-generate-output-graphs.R#91 | Main functions work together | testing output of fm_generate_graphs |
expect_type(result_graph, “list”) | [ |
test-main-r-part3-generate-output-graphs.R#92 | Main functions work together | testing output of fm_generate_graphs |
expect_s3_class(result_graph[[“pred_plot”]], “ggplot”) | [ |
test-main-r-part3-generate-output-graphs.R#93 | Main functions work together | expect_s3_class(result_graph[[“eta_plot”]], “ggplot”) | [ |