Skip to content

Commit

Permalink
Fix for covrage .yaml not uploading files
Browse files Browse the repository at this point in the history
split developer only tests
  • Loading branch information
Piotr Chlebicki committed Jul 15, 2024
1 parent f92547f commit d807dbd
Show file tree
Hide file tree
Showing 5 changed files with 338 additions and 176 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ jobs:

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
3 changes: 2 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ knitr::opts_chunk$set(
[![R-CMD-check](https://github.com/ncn-foreigners/singleRcapture/workflows/R-CMD-check/badge.svg)](https://github.com/ncn-foreigners/singleRcapture/actions)
[![Codecov test coverage](https://codecov.io/gh/ncn-foreigners/singleRcapture/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ncn-foreigners/singleRcapture?branch=main)
[![CRAN status](https://www.r-pkg.org/badges/version/singleRcapture)](https://CRAN.R-project.org/package=singleRcapture)
[![CRAN downloads](http://cranlogs.r-pkg.org/badges/grand-total/singleRcapture?color=blue)](https://cran.r-project.org/package=singleRcapture)
[![CRAN downloads](http://cranlogs.r-pkg.org/badges/grand-total/singleRcapture)](https://cran.r-project.org/package=singleRcapture)
[![CRAN downloads](https://cranlogs.r-pkg.org/badges/singleRcapture)](https://cran.r-project.org/package=singleRcapture)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8436043.svg)](https://doi.org/10.5281/zenodo.8436043)
<!-- badges: end -->

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ coverage](https://codecov.io/gh/ncn-foreigners/singleRcapture/branch/main/graph/
[![CRAN
status](https://www.r-pkg.org/badges/version/singleRcapture)](https://CRAN.R-project.org/package=singleRcapture)
[![CRAN
downloads](http://cranlogs.r-pkg.org/badges/grand-total/singleRcapture?color=blue)](https://cran.r-project.org/package=singleRcapture)
downloads](http://cranlogs.r-pkg.org/badges/grand-total/singleRcapture)](https://cran.r-project.org/package=singleRcapture)
[![CRAN
downloads](https://cranlogs.r-pkg.org/badges/singleRcapture)](https://cran.r-project.org/package=singleRcapture)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8436043.svg)](https://doi.org/10.5281/zenodo.8436043)
<!-- badges: end -->

Expand Down
331 changes: 331 additions & 0 deletions inst/tinytest/Developer_only.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,331 @@
# These tests are only supposed to be run on developer's machine and
# package GitHub page not on CRAN (they take too long)

if (isTRUE(tolower(Sys.getenv("TEST_SINGLERCAPTURE_MULTICORE_DEVELOPER")) == "true")) {
set.seed(123)
expect_silent(
estimatePopsize(
formula = TOTAL_SUB ~ .,
data = farmsubmission,
model = "zotpoisson",
popVar = "bootstrap",
controlMethod = controlMethod(epsilon = 1e-6, silent = TRUE),# testing silent
controlPopVar = controlPopVar(
B = 140,
bootstrapFitcontrol = controlMethod(
silent = TRUE,
epsilon = .Machine$double.eps
),
cores = 2L
)
)
)

expect_silent(
estimatePopsize(
formula = capture ~ gender,
data = netherlandsimmigrant,
model = "zotgeom",
method = "optim",
popVar = "bootstrap",
controlMethod = controlMethod(epsilon = 1e-6, silent = TRUE),# testing silent
controlPopVar = controlPopVar(
B = 70,
cores = 2L, bootstrapFitcontrol = controlMethod(),
bootType = "nonparametric"
)
)
)

expect_silent(
estimatePopsize(
formula = TOTAL_SUB ~ .,
data = farmsubmission,
model = "oiztgeom",
popVar = "bootstrap",
controlModel = controlModel(omegaFormula = ~ .),
controlMethod = controlMethod(silent = TRUE),# testing silent
controlPopVar = controlPopVar(
B = 35,
cores = 2L, bootstrapFitcontrol = controlMethod(),
bootType = "semiparametric"
)
)
)

df <- farmsubmission[, c(1,4)]
df$ww <- 0
### this is dplyr::count but slower and without dependencies
df <- aggregate(ww ~ ., df, FUN = length)

expect_silent(
estimatePopsize(
formula = TOTAL_SUB ~ C_TYPE,
data = df,
model = ztpoisson,
popVar = "bootstrap",
weights = df$ww,
controlMethod = controlMethod(silent = TRUE),
controlModel = controlModel(weightsAsCounts = TRUE),
controlPopVar = controlPopVar(
B = 70,
cores = 2L,
bootType = "semiparametric"
)
)
)

expect_silent(
estimatePopsize(
formula = TOTAL_SUB ~ C_TYPE,
data = df,
model = ztoipoisson,
popVar = "bootstrap",
weights = df$ww,
controlMethod = controlMethod(silent = TRUE),
controlModel = controlModel(weightsAsCounts = TRUE),
controlPopVar = controlPopVar(
B = 70,
cores = 2L,
bootType = "parametric"
)
)
)

expect_silent(
estimatePopsize(
formula = TOTAL_SUB ~ C_TYPE,
data = df,
model = ztoigeom,
popVar = "bootstrap",
weights = df$ww,
controlMethod = controlMethod(silent = TRUE),
controlModel = controlModel(weightsAsCounts = TRUE),
controlPopVar = controlPopVar(
B = 70,
cores = 2L,
bootType = "nonparametric"
)
)
)

expect_silent(
estimatePopsize(
formula = TOTAL_SUB ~ C_TYPE,
data = df,
model = chao,
popVar = "bootstrap",
weights = df$ww,
controlMethod = controlMethod(silent = TRUE),
controlModel = controlModel(weightsAsCounts = TRUE),
controlPopVar = controlPopVar(
B = 70,
bootType = "nonparametric"
)
)
)

expect_silent(
estimatePopsize(
formula = TOTAL_SUB ~ C_TYPE,
data = df,
model = zelterman,
popVar = "bootstrap",
weights = df$ww,
controlMethod = controlMethod(silent = TRUE),
controlModel = controlModel(weightsAsCounts = TRUE),
controlPopVar = controlPopVar(
B = 70,
bootType = "semiparametric"
)
)
)

expect_silent(
estimatePopsize(
formula = TOTAL_SUB ~ C_TYPE,
data = df,
model = ztgeom,
popVar = "bootstrap",
weights = df$ww,
controlMethod = controlMethod(silent = TRUE),
controlModel = controlModel(weightsAsCounts = TRUE),
controlPopVar = controlPopVar(
B = 70,
bootType = "parametric"
)
)
)
}# These tests are only supposed to be run on developer's machine and
# package GitHub page not on CRAN (they take too long)

if (isTRUE(tolower(Sys.getenv("TEST_SINGLERCAPTURE_MULTICORE_DEVELOPER")) == "true")) {
set.seed(123)
expect_silent(
xx <- estimatePopsize(
formula = TOTAL_SUB ~ .,
data = farmsubmission,
model = "zotpoisson",
popVar = "bootstrap",
controlMethod = controlMethod(epsilon = 1e-6, silent = TRUE),# testing silent
controlPopVar = controlPopVar(
B = 140,
bootstrapFitcontrol = controlMethod(
silent = TRUE,
epsilon = .Machine$double.eps
),
cores = 2L
)
)
)

expect_silent(
predict(
xx,
type = "mean"
)
)

expect_silent(
xx <- estimatePopsize(
formula = capture ~ gender,
data = netherlandsimmigrant,
model = "zotgeom",
method = "optim",
popVar = "bootstrap",
controlMethod = controlMethod(epsilon = 1e-6, silent = TRUE),# testing silent
controlPopVar = controlPopVar(
B = 70,
cores = 2L, bootstrapFitcontrol = controlMethod(),
bootType = "nonparametric"
)
)
)

expect_silent(
predict(
xx,
type = "mean"
)
)

expect_silent(
estimatePopsize(
formula = TOTAL_SUB ~ .,
data = farmsubmission,
model = "oiztgeom",
popVar = "bootstrap",
controlModel = controlModel(omegaFormula = ~ .),
controlMethod = controlMethod(silent = TRUE),# testing silent
controlPopVar = controlPopVar(
B = 35,
cores = 2L, bootstrapFitcontrol = controlMethod(),
bootType = "semiparametric"
)
)
)

df <- farmsubmission[, c(1,4)]
df$ww <- 0
### this is dplyr::count but slower and without dependencies
df <- aggregate(ww ~ ., df, FUN = length)

expect_silent(
estimatePopsize(
formula = TOTAL_SUB ~ C_TYPE,
data = df,
model = ztpoisson,
popVar = "bootstrap",
weights = df$ww,
controlMethod = controlMethod(silent = TRUE),
controlModel = controlModel(weightsAsCounts = TRUE),
controlPopVar = controlPopVar(
B = 70,
cores = 2L,
bootType = "semiparametric"
)
)
)

expect_silent(
estimatePopsize(
formula = TOTAL_SUB ~ C_TYPE,
data = df,
model = ztoipoisson,
popVar = "bootstrap",
weights = df$ww,
controlMethod = controlMethod(silent = TRUE),
controlModel = controlModel(weightsAsCounts = TRUE),
controlPopVar = controlPopVar(
B = 70,
cores = 2L,
bootType = "parametric"
)
)
)

expect_silent(
estimatePopsize(
formula = TOTAL_SUB ~ C_TYPE,
data = df,
model = ztoigeom,
popVar = "bootstrap",
weights = df$ww,
controlMethod = controlMethod(silent = TRUE),
controlModel = controlModel(weightsAsCounts = TRUE),
controlPopVar = controlPopVar(
B = 70,
cores = 2L,
bootType = "nonparametric"
)
)
)

expect_silent(
estimatePopsize(
formula = TOTAL_SUB ~ C_TYPE,
data = df,
model = chao,
popVar = "bootstrap",
weights = df$ww,
controlMethod = controlMethod(silent = TRUE),
controlModel = controlModel(weightsAsCounts = TRUE),
controlPopVar = controlPopVar(
B = 70,
bootType = "nonparametric"
)
)
)

expect_silent(
estimatePopsize(
formula = TOTAL_SUB ~ C_TYPE,
data = df,
model = zelterman,
popVar = "bootstrap",
weights = df$ww,
controlMethod = controlMethod(silent = TRUE),
controlModel = controlModel(weightsAsCounts = TRUE),
controlPopVar = controlPopVar(
B = 70,
bootType = "semiparametric"
)
)
)

expect_silent(
estimatePopsize(
formula = TOTAL_SUB ~ C_TYPE,
data = df,
model = ztgeom,
popVar = "bootstrap",
weights = df$ww,
controlMethod = controlMethod(silent = TRUE),
controlModel = controlModel(weightsAsCounts = TRUE),
controlPopVar = controlPopVar(
B = 70,
bootType = "parametric"
)
)
)
}
Loading

0 comments on commit d807dbd

Please sign in to comment.