Skip to content

Commit

Permalink
Style generated code (#56)
Browse files Browse the repository at this point in the history
* Style generated code

* Fix templates, style generated automatically
  • Loading branch information
mikemahoney218 committed Oct 16, 2023
1 parent 60f3cb1 commit ac3fa7f
Show file tree
Hide file tree
Showing 28 changed files with 35 additions and 189 deletions.
3 changes: 2 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ release_bullets <- function() {
c(
"`cffr::cff_write()`",
"`codemetar::write_codemeta()`",
"`styler::style_pkg()`"
"`styler::style_pkg()`",
"`Rscript inst/generate_srr.R`"
)
}
1 change: 1 addition & 0 deletions inst/generate_srr.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ for (name in spatial_yardstick) {
generated_template,
file.path("tests", "testthat", paste0("test-srr-", name, ".R"))
)
styler::style_file(file.path("tests", "testthat", paste0("test-srr-", name, ".R")))
}
10 changes: 0 additions & 10 deletions inst/srr_template_nonspatial_yardstick.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ test_that("srr: {{{name}}} errors if truth and estimate are list columns", {
})

test_that("srr: {{{name}}} removes NaN and NA when na_rm = TRUE", {

missing_df <- tibble::tibble(x = c(NaN, 2:5), y = c(1:4, NA))

expect_snapshot(
Expand All @@ -69,7 +68,6 @@ test_that("srr: {{{name}}} removes NaN and NA when na_rm = TRUE", {
})

test_that("srr: {{{name}}} returns NA when na_rm = FALSE and NA is present", {

missing_df <- tibble::tibble(x = c(NaN, 2:5), y = c(1:4, NA))

expect_identical(
Expand All @@ -91,11 +89,9 @@ test_that("srr: {{{name}}} returns NA when na_rm = FALSE and NA is present", {
{{{name}}}_vec(missing_df$x, missing_df$y, na_rm = FALSE),
NA_real_
)

})

test_that("srr: {{{name}}} errors on zero-length data", {

expect_snapshot(
{{{name}}}_vec(numeric(), numeric()),
error = TRUE
Expand All @@ -114,7 +110,6 @@ test_that("srr: {{{name}}} errors on zero-length data", {
})

test_that("srr: {{{name}}} errors on all-NA data", {

expect_snapshot(
{{{name}}}_vec(rep(NA_real_, 4), 4:1),
error = TRUE
Expand All @@ -139,12 +134,10 @@ test_that("srr: {{{name}}} errors on all-NA data", {
expect_snapshot(
{{{name}}}_vec(1:4, 1:4)
)

})


test_that("srr: {{{name}}} works with all identical data", {

all_identical <- tibble::tibble(x = 1:4, y = 1:4)
expect_snapshot(
{{{name}}}(all_identical, x, y)
Expand All @@ -158,7 +151,6 @@ test_that("srr: {{{name}}} works with all identical data", {
expect_snapshot(
{{{name}}}(all_identical, x, y)
)

})

test_that("srr: {{{name}}} results don't change with trivial noise", {
Expand Down Expand Up @@ -188,7 +180,6 @@ test_that("srr: {{{name}}} results don't change with trivial noise", {
{{{name}}}_vec(y, noised_x),
{{{name}}}_vec(y, x)
)

})

test_that("srr: {{{name}}} results don't change with different seeds", {
Expand Down Expand Up @@ -240,5 +231,4 @@ test_that("srr: {{{name}}} results don't change with different seeds", {
{{{name}}}_vec(y, x)
)
)

})
2 changes: 0 additions & 2 deletions inst/srr_template_spatial_yardstick.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ test_that("srr: expected failures for {{{name}}}", {
expect_snapshot(
{{{name}}}(worldclim_simulation, response, response)
)

})

test_that("other generic srr standards", {
Expand Down Expand Up @@ -454,5 +453,4 @@ test_that("other generic srr standards", {
{{{name}}}_vec(worldclim_loaded$bio13, worldclim_loaded$bio19, other_weights)
)
)

})
10 changes: 0 additions & 10 deletions tests/testthat/test-srr-ww_agreement_coefficient.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ test_that("srr: ww_agreement_coefficient errors if truth and estimate are list c
})

test_that("srr: ww_agreement_coefficient removes NaN and NA when na_rm = TRUE", {

missing_df <- tibble::tibble(x = c(NaN, 2:5), y = c(1:4, NA))

expect_snapshot(
Expand All @@ -72,7 +71,6 @@ test_that("srr: ww_agreement_coefficient removes NaN and NA when na_rm = TRUE",
})

test_that("srr: ww_agreement_coefficient returns NA when na_rm = FALSE and NA is present", {

missing_df <- tibble::tibble(x = c(NaN, 2:5), y = c(1:4, NA))

expect_identical(
Expand All @@ -94,11 +92,9 @@ test_that("srr: ww_agreement_coefficient returns NA when na_rm = FALSE and NA is
ww_agreement_coefficient_vec(missing_df$x, missing_df$y, na_rm = FALSE),
NA_real_
)

})

test_that("srr: ww_agreement_coefficient errors on zero-length data", {

expect_snapshot(
ww_agreement_coefficient_vec(numeric(), numeric()),
error = TRUE
Expand All @@ -117,7 +113,6 @@ test_that("srr: ww_agreement_coefficient errors on zero-length data", {
})

test_that("srr: ww_agreement_coefficient errors on all-NA data", {

expect_snapshot(
ww_agreement_coefficient_vec(rep(NA_real_, 4), 4:1),
error = TRUE
Expand All @@ -142,12 +137,10 @@ test_that("srr: ww_agreement_coefficient errors on all-NA data", {
expect_snapshot(
ww_agreement_coefficient_vec(1:4, 1:4)
)

})


test_that("srr: ww_agreement_coefficient works with all identical data", {

all_identical <- tibble::tibble(x = 1:4, y = 1:4)
expect_snapshot(
ww_agreement_coefficient(all_identical, x, y)
Expand All @@ -161,7 +154,6 @@ test_that("srr: ww_agreement_coefficient works with all identical data", {
expect_snapshot(
ww_agreement_coefficient(all_identical, x, y)
)

})

test_that("srr: ww_agreement_coefficient results don't change with trivial noise", {
Expand Down Expand Up @@ -191,7 +183,6 @@ test_that("srr: ww_agreement_coefficient results don't change with trivial noise
ww_agreement_coefficient_vec(y, noised_x),
ww_agreement_coefficient_vec(y, x)
)

})

test_that("srr: ww_agreement_coefficient results don't change with different seeds", {
Expand Down Expand Up @@ -243,5 +234,4 @@ test_that("srr: ww_agreement_coefficient results don't change with different see
ww_agreement_coefficient_vec(y, x)
)
)

})
2 changes: 0 additions & 2 deletions tests/testthat/test-srr-ww_global_geary_c.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ test_that("srr: expected failures for ww_global_geary_c", {
expect_snapshot(
ww_global_geary_c(worldclim_simulation, response, response)
)

})

test_that("other generic srr standards", {
Expand Down Expand Up @@ -457,5 +456,4 @@ test_that("other generic srr standards", {
ww_global_geary_c_vec(worldclim_loaded$bio13, worldclim_loaded$bio19, other_weights)
)
)

})
2 changes: 0 additions & 2 deletions tests/testthat/test-srr-ww_global_geary_pvalue.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ test_that("srr: expected failures for ww_global_geary_pvalue", {
expect_snapshot(
ww_global_geary_pvalue(worldclim_simulation, response, response)
)

})

test_that("other generic srr standards", {
Expand Down Expand Up @@ -457,5 +456,4 @@ test_that("other generic srr standards", {
ww_global_geary_pvalue_vec(worldclim_loaded$bio13, worldclim_loaded$bio19, other_weights)
)
)

})
2 changes: 0 additions & 2 deletions tests/testthat/test-srr-ww_global_moran_i.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ test_that("srr: expected failures for ww_global_moran_i", {
expect_snapshot(
ww_global_moran_i(worldclim_simulation, response, response)
)

})

test_that("other generic srr standards", {
Expand Down Expand Up @@ -457,5 +456,4 @@ test_that("other generic srr standards", {
ww_global_moran_i_vec(worldclim_loaded$bio13, worldclim_loaded$bio19, other_weights)
)
)

})
2 changes: 0 additions & 2 deletions tests/testthat/test-srr-ww_global_moran_pvalue.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ test_that("srr: expected failures for ww_global_moran_pvalue", {
expect_snapshot(
ww_global_moran_pvalue(worldclim_simulation, response, response)
)

})

test_that("other generic srr standards", {
Expand Down Expand Up @@ -457,5 +456,4 @@ test_that("other generic srr standards", {
ww_global_moran_pvalue_vec(worldclim_loaded$bio13, worldclim_loaded$bio19, other_weights)
)
)

})
2 changes: 0 additions & 2 deletions tests/testthat/test-srr-ww_local_geary_c.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ test_that("srr: expected failures for ww_local_geary_c", {
expect_snapshot(
ww_local_geary_c(worldclim_simulation, response, response)
)

})

test_that("other generic srr standards", {
Expand Down Expand Up @@ -457,5 +456,4 @@ test_that("other generic srr standards", {
ww_local_geary_c_vec(worldclim_loaded$bio13, worldclim_loaded$bio19, other_weights)
)
)

})
26 changes: 16 additions & 10 deletions tests/testthat/test-srr-ww_local_geary_pvalue.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ test_that("srr: expected failures for ww_local_geary_pvalue", {
expect_snapshot(
ww_local_geary_pvalue(worldclim_simulation, response, response)
)

})

test_that("other generic srr standards", {
Expand Down Expand Up @@ -282,7 +281,8 @@ test_that("other generic srr standards", {
withr::with_seed(
1107,
ww_local_geary_pvalue(worldclim_predicted, predicted, response, nsim = 10000)
), tolerance = 0.1
),
tolerance = 0.1
)

#' @srrstats {G3.0} Testing with appropriate tolerances.
Expand All @@ -297,7 +297,8 @@ test_that("other generic srr standards", {
withr::with_seed(
1107,
ww_local_geary_pvalue(worldclim_predicted, response, predicted, nsim = 10000)
), tolerance = 0.1
),
tolerance = 0.1
)

#' @srrstats {G3.0} Testing with appropriate tolerances.
Expand All @@ -312,7 +313,8 @@ test_that("other generic srr standards", {
withr::with_seed(
1107,
ww_local_geary_pvalue_vec(worldclim_predicted$response, worldclim_predicted$predicted, worldclim_weights, nsim = 10000)
), tolerance = 0.1
),
tolerance = 0.1
)

#' @srrstats {G3.0} Testing with appropriate tolerances.
Expand All @@ -327,7 +329,8 @@ test_that("other generic srr standards", {
withr::with_seed(
1107,
ww_local_geary_pvalue_vec(worldclim_predicted$predicted, worldclim_predicted$response, worldclim_weights, nsim = 10000)
), tolerance = 0.1
),
tolerance = 0.1
)

guerry_modeled <- guerry
Expand All @@ -345,7 +348,8 @@ test_that("other generic srr standards", {
#' @srrstats {SP6.2} Testing with ~global data
expect_equal(
ww_local_geary_pvalue(guerry_modeled, predictions, Crm_prs, nsim = 10000)$.estimate,
ww_local_geary_pvalue(guerry_modeled_geo, predictions, Crm_prs, nsim = 10000)$.estimate, tolerance = 0.1
ww_local_geary_pvalue(guerry_modeled_geo, predictions, Crm_prs, nsim = 10000)$.estimate,
tolerance = 0.1
)

#' @srrstats {G3.0} Testing with appropriate tolerances.
Expand All @@ -354,7 +358,8 @@ test_that("other generic srr standards", {
#' @srrstats {SP6.2} Testing with ~global data
expect_equal(
ww_local_geary_pvalue(guerry_modeled, Crm_prs, predictions, nsim = 10000)$.estimate,
ww_local_geary_pvalue(guerry_modeled_geo, Crm_prs, predictions, nsim = 10000)$.estimate, tolerance = 0.1
ww_local_geary_pvalue(guerry_modeled_geo, Crm_prs, predictions, nsim = 10000)$.estimate,
tolerance = 0.1
)

#' @srrstats {G3.0} Testing with appropriate tolerances.
Expand All @@ -363,7 +368,8 @@ test_that("other generic srr standards", {
#' @srrstats {SP6.2} Testing with ~global data
expect_equal(
ww_local_geary_pvalue_vec(guerry_modeled$Crm_prs, guerry_modeled$predictions, guerry_weights, nsim = 10000),
ww_local_geary_pvalue_vec(guerry_modeled_geo$Crm_prs, guerry_modeled_geo$predictions, guerry_weights_geo, nsim = 10000), tolerance = 0.1
ww_local_geary_pvalue_vec(guerry_modeled_geo$Crm_prs, guerry_modeled_geo$predictions, guerry_weights_geo, nsim = 10000),
tolerance = 0.1
)

#' @srrstats {G3.0} Testing with appropriate tolerances.
Expand All @@ -372,7 +378,8 @@ test_that("other generic srr standards", {
#' @srrstats {SP6.2} Testing with ~global data
expect_equal(
ww_local_geary_pvalue_vec(guerry_modeled$predictions, guerry_modeled$Crm_prs, guerry_weights, nsim = 10000),
ww_local_geary_pvalue_vec(guerry_modeled_geo$predictions, guerry_modeled_geo$Crm_prs, guerry_weights_geo, nsim = 10000), tolerance = 0.1
ww_local_geary_pvalue_vec(guerry_modeled_geo$predictions, guerry_modeled_geo$Crm_prs, guerry_weights_geo, nsim = 10000),
tolerance = 0.1
)

#' @srrstats {SP2.3} Testing with loaded sf objects:
Expand Down Expand Up @@ -457,5 +464,4 @@ test_that("other generic srr standards", {
ww_local_geary_pvalue_vec(worldclim_loaded$bio13, worldclim_loaded$bio19, other_weights)
)
)

})
2 changes: 0 additions & 2 deletions tests/testthat/test-srr-ww_local_getis_ord_g.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ test_that("srr: expected failures for ww_local_getis_ord_g", {
expect_snapshot(
ww_local_getis_ord_g(worldclim_simulation, response, response)
)

})

test_that("other generic srr standards", {
Expand Down Expand Up @@ -457,5 +456,4 @@ test_that("other generic srr standards", {
ww_local_getis_ord_g_vec(worldclim_loaded$bio13, worldclim_loaded$bio19, other_weights)
)
)

})
Loading

0 comments on commit ac3fa7f

Please sign in to comment.