Skip to content

Commit

Permalink
skipping tests on Cran
Browse files Browse the repository at this point in the history
  • Loading branch information
abigailkeller committed Oct 4, 2024
1 parent c5da2ea commit 7b1e100
Show file tree
Hide file tree
Showing 9 changed files with 561 additions and 548 deletions.
4 changes: 2 additions & 2 deletions .Rhistory
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"detections among replicates.")
errMsg2 <- 'See the eDNAjoint guide for data formatting help: '
errMsg3 <- paste0('https://bookdown.org/abigailkeller/eDNAjoint_vignette',
'/usecase1.html#prepare-the-data')
errMsg <- paste(errMsg1,errMsg2,errMsg3, sep = "\n")
Expand Down Expand Up @@ -510,3 +508,5 @@ print('no')
}
roxygen2::roxygenise()
codemetar::write_codemeta()
codemetar::write_codemeta()
roxygen2::roxygenise()
2 changes: 1 addition & 1 deletion R/globals.R
Original file line number Diff line number Diff line change
@@ -1 +1 @@
utils::globalVariables(c("L","median","survey_type","inits"))
utils::globalVariables(c("L","median","survey_type","inits","value"))
129 changes: 65 additions & 64 deletions tests/testthat/test-detectionCalculate.R
Original file line number Diff line number Diff line change
@@ -1,64 +1,65 @@
test_that("detectionCalculate input checks work", {
#' @srrstats {G5.2,G5.2b} Tests the assure function input checks are behaving
#' as expected.
# run joint model to do tests with
model1 <- suppressWarnings({jointModel(data = gobyData,
cov = c('Filter_time','Salinity'),
n.chain = 1,n.iter.burn = 25,
n.iter.sample = 75,multicore = FALSE)})

model2 <- suppressWarnings({jointModel(data = greencrabData,family = 'negbin',
n.chain = 1,n.iter.burn = 25,
n.iter.sample = 75,multicore = FALSE)})

#1. make sure model fit is of class stanfit
expect_error(detectionCalculate(as.matrix(model1$model), mu = c(0.1, 0.5),
cov.val = c(0,0)),
"modelfit must be of class 'stanfit'.")

#2. make sure ci is valid
expect_error(detectionCalculate(model1$model, mu = c('0', 0.5),
cov.val = c(0,0)),
"mu must be a numeric vector of positive values")

#3. make sure mu is a numeric vector of positive values
expect_error(detectionCalculate(model1$model, mu = c(0, 0.5),
cov.val = c(0,0)),
"mu must be a numeric vector of positive values")

#4. make sure probability is a numeric value between 0 and 1
expect_error(detectionCalculate(model1$model, mu = c(0.1, 0.5),
cov.val = c(0,0), probability = 1.05),
"probability must be a numeric value between 0 and 1")

#5. cov.val is numeric, if provided
expect_error(detectionCalculate(model1$model, mu = c(0.1, 0.5),
cov.val = c('0',0)),
"cov.val must be a numeric vector")

#6. Only include input cov.val if covariates are included in model
expect_error(detectionCalculate(model2$model, mu = c(0.1, 0.5),
cov.val = c(0,0)),
paste0("cov.val must be NULL if the model does not ",
"contain site-level covariates."))

#7. Input cov.val is the same length as the number of estimated covariates.
expect_error(detectionCalculate(model1$model, mu = c(0.1, 0.5),
cov.val = c(0,0,0)),
paste0("cov.val must be of the same length as the number of ",
"non-intercept site-level coefficients in the model."))

#8. If covariates are in model, cov.val must be provided
expect_error(detectionCalculate(model1$model, mu = c(0.1, 0.5)),
paste0("cov.val must be provided if the model contains ",
"site-level covariates."))

#9. qPCR.N must be an integer
expect_error(detectionCalculate(model1$model, mu = c(0.1, 0.5),
cov.val = c(0,0), qPCR.N = 6.8),
"qPCR.N should be an integer.")
})




test_that("detectionCalculate input checks work", {
testthat::skip_on_cran()
#' @srrstats {G5.2,G5.2b} Tests the assure function input checks are behaving
#' as expected.
# run joint model to do tests with
model1 <- suppressWarnings({jointModel(data = gobyData,
cov = c('Filter_time','Salinity'),
n.chain = 1,n.iter.burn = 25,
n.iter.sample = 75,multicore = FALSE)})

model2 <- suppressWarnings({jointModel(data = greencrabData,family = 'negbin',
n.chain = 1,n.iter.burn = 25,
n.iter.sample = 75,multicore = FALSE)})

#1. make sure model fit is of class stanfit
expect_error(detectionCalculate(as.matrix(model1$model), mu = c(0.1, 0.5),
cov.val = c(0,0)),
"modelfit must be of class 'stanfit'.")

#2. make sure ci is valid
expect_error(detectionCalculate(model1$model, mu = c('0', 0.5),
cov.val = c(0,0)),
"mu must be a numeric vector of positive values")

#3. make sure mu is a numeric vector of positive values
expect_error(detectionCalculate(model1$model, mu = c(0, 0.5),
cov.val = c(0,0)),
"mu must be a numeric vector of positive values")

#4. make sure probability is a numeric value between 0 and 1
expect_error(detectionCalculate(model1$model, mu = c(0.1, 0.5),
cov.val = c(0,0), probability = 1.05),
"probability must be a numeric value between 0 and 1")

#5. cov.val is numeric, if provided
expect_error(detectionCalculate(model1$model, mu = c(0.1, 0.5),
cov.val = c('0',0)),
"cov.val must be a numeric vector")

#6. Only include input cov.val if covariates are included in model
expect_error(detectionCalculate(model2$model, mu = c(0.1, 0.5),
cov.val = c(0,0)),
paste0("cov.val must be NULL if the model does not ",
"contain site-level covariates."))

#7. Input cov.val is the same length as the number of estimated covariates.
expect_error(detectionCalculate(model1$model, mu = c(0.1, 0.5),
cov.val = c(0,0,0)),
paste0("cov.val must be of the same length as the number of ",
"non-intercept site-level coefficients in the model."))

#8. If covariates are in model, cov.val must be provided
expect_error(detectionCalculate(model1$model, mu = c(0.1, 0.5)),
paste0("cov.val must be provided if the model contains ",
"site-level covariates."))

#9. qPCR.N must be an integer
expect_error(detectionCalculate(model1$model, mu = c(0.1, 0.5),
cov.val = c(0,0), qPCR.N = 6.8),
"qPCR.N should be an integer.")
})




149 changes: 75 additions & 74 deletions tests/testthat/test-detectionPlot.R
Original file line number Diff line number Diff line change
@@ -1,74 +1,75 @@
test_that("detectionPlot input checks work", {
#' @srrstats {G5.2,G5.2b} Tests the assure function input checks are behaving
#' as expected.
# run joint model to do tests with
model1 <- suppressWarnings({jointModel(data = gobyData,
cov = c('Filter_time','Salinity'),
n.chain = 1,n.iter.burn = 25,
n.iter.sample = 75,
multicore = FALSE)})

model2 <- suppressWarnings({jointModel(data = greencrabData,
family = 'negbin',
n.chain = 1,n.iter.burn = 25,
n.iter.sample = 75,multicore = FALSE)})

#1. make sure model fit is of class stanfit
expect_error(detectionPlot(as.matrix(model1$model), mu.min = 0.1,
mu.max = 1, cov.val = c(0,0)),
"modelfit must be of class 'stanfit'.")

#2. make sure mu.min is a numeric value
expect_error(detectionPlot(model1$model, mu.min = '0.1', mu.max = 1,
cov.val = c(0,0)),
"mu.min must be a numeric value greater than 0")

#3. make sure mu.min is a numeric value
expect_error(detectionPlot(model1$model, mu.min = 0, mu.max = 1,
cov.val = c(0,0)),
"mu.min must be a numeric value greater than 0")

#4. make sure mu.max is a numeric value
expect_error(detectionPlot(model1$model, mu.min = 0.1, mu.max = '1',
cov.val = c(0,0)),
"mu.max must be a numeric value greater than mu.min")

#5. make sure mu.max is a numeric value
expect_error(detectionPlot(model1$model, mu.min = 0.1, mu.max = 0.1,
cov.val = c(0,0)),
"mu.max must be a numeric value greater than mu.min")

#6. make sure mu.max is a numeric value
expect_error(detectionPlot(model1$model, mu.min = 0.1, mu.max = 1,
cov.val = c(0,0), probability = 1.1),
"probability must be a numeric value between 0 and 1")

#7. cov.val is numeric, if provided
expect_error(detectionPlot(model1$model, mu.min = 0.1, mu.max = 1,
cov.val = c(0,'0')),
"cov.val must be a numeric vector")

#8. Only include input cov.val if covariates are included in model
expect_error(detectionPlot(model2$model, mu.min = 0.1, mu.max = 1,
cov.val = c(0,0)),
paste0("cov.val must be NULL if the model does not contain ",
"site-level covariates."))

#9. Input cov.val is the same length as the number of estimated covariates.
expect_error(detectionPlot(model1$model, mu.min = 0.1, mu.max = 1,
cov.val = c(0,0,0)),
paste0("cov.val must be of the same length as the number of ",
"non-intercept site-level coefficients in the model."))

#10. If covariates are in model, cov.val must be provided
expect_error(detectionPlot(model1$model, mu.min = 0.1, mu.max = 1),
paste0("cov.val must be provided if the model contains ",
"site-level covariates."))

#11. qPCR.N must be an integer
expect_error(detectionPlot(model1$model, mu.min = 0.1, mu.max = 1,
cov.val = c(0,0), qPCR.N = 6.8),
"qPCR.N should be an integer.")
})


test_that("detectionPlot input checks work", {
testthat::skip_on_cran()
#' @srrstats {G5.2,G5.2b} Tests the assure function input checks are behaving
#' as expected.
# run joint model to do tests with
model1 <- suppressWarnings({jointModel(data = gobyData,
cov = c('Filter_time','Salinity'),
n.chain = 1,n.iter.burn = 25,
n.iter.sample = 75,
multicore = FALSE)})

model2 <- suppressWarnings({jointModel(data = greencrabData,
family = 'negbin',
n.chain = 1,n.iter.burn = 25,
n.iter.sample = 75,multicore = FALSE)})

#1. make sure model fit is of class stanfit
expect_error(detectionPlot(as.matrix(model1$model), mu.min = 0.1,
mu.max = 1, cov.val = c(0,0)),
"modelfit must be of class 'stanfit'.")

#2. make sure mu.min is a numeric value
expect_error(detectionPlot(model1$model, mu.min = '0.1', mu.max = 1,
cov.val = c(0,0)),
"mu.min must be a numeric value greater than 0")

#3. make sure mu.min is a numeric value
expect_error(detectionPlot(model1$model, mu.min = 0, mu.max = 1,
cov.val = c(0,0)),
"mu.min must be a numeric value greater than 0")

#4. make sure mu.max is a numeric value
expect_error(detectionPlot(model1$model, mu.min = 0.1, mu.max = '1',
cov.val = c(0,0)),
"mu.max must be a numeric value greater than mu.min")

#5. make sure mu.max is a numeric value
expect_error(detectionPlot(model1$model, mu.min = 0.1, mu.max = 0.1,
cov.val = c(0,0)),
"mu.max must be a numeric value greater than mu.min")

#6. make sure mu.max is a numeric value
expect_error(detectionPlot(model1$model, mu.min = 0.1, mu.max = 1,
cov.val = c(0,0), probability = 1.1),
"probability must be a numeric value between 0 and 1")

#7. cov.val is numeric, if provided
expect_error(detectionPlot(model1$model, mu.min = 0.1, mu.max = 1,
cov.val = c(0,'0')),
"cov.val must be a numeric vector")

#8. Only include input cov.val if covariates are included in model
expect_error(detectionPlot(model2$model, mu.min = 0.1, mu.max = 1,
cov.val = c(0,0)),
paste0("cov.val must be NULL if the model does not contain ",
"site-level covariates."))

#9. Input cov.val is the same length as the number of estimated covariates.
expect_error(detectionPlot(model1$model, mu.min = 0.1, mu.max = 1,
cov.val = c(0,0,0)),
paste0("cov.val must be of the same length as the number of ",
"non-intercept site-level coefficients in the model."))

#10. If covariates are in model, cov.val must be provided
expect_error(detectionPlot(model1$model, mu.min = 0.1, mu.max = 1),
paste0("cov.val must be provided if the model contains ",
"site-level covariates."))

#11. qPCR.N must be an integer
expect_error(detectionPlot(model1$model, mu.min = 0.1, mu.max = 1,
cov.val = c(0,0), qPCR.N = 6.8),
"qPCR.N should be an integer.")
})


4 changes: 4 additions & 0 deletions tests/testthat/test-jointModel.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test_that("jointModel input checks work", {
testthat::skip_on_cran()
#' @srrstats {G5.2,G5.2b,BS2.15} Tests the assure function input checks are
#' behaving as expected.
#1. input tags are valid, q = FALSE, cov = FALSE
Expand Down Expand Up @@ -849,6 +850,7 @@ test_that("jointModel input checks work", {
#' values are within the 95% credibility interval of the parameters'
#' posteriors in the function output.
test_that("jointModel parameter recovery tests work",{
testthat::skip_on_cran()

################################
# model run 1: smaller dataset #
Expand Down Expand Up @@ -1146,6 +1148,7 @@ test_that("jointModel parameter recovery tests work",{


test_that("jointModel probability distribution tests work",{
testthat::skip_on_cran()

#' @srrstats {PD4.2} This package fits models with fixed distributions to
#' data. Users can choose the distribution used to represent the
Expand Down Expand Up @@ -1234,6 +1237,7 @@ test_that("jointModel probability distribution tests work",{
})

test_that("semi-paired model works", {
testthat::skip_on_cran()

## 1.
# model includes 'p10','q','phi','beta'
Expand Down
Loading

0 comments on commit 7b1e100

Please sign in to comment.