The blockCV package creates spatially or environmentally separated training and testing folds for cross-validation to provide a robust error estimation in spatially structured environments. See
This causes tests with expect_silent() to error as the function actually returns \n.
The cat() should be conditioned under the report block to not always print an empty line and probably also only appear within the warning() calls itself and not be executed standalone.
You can verify this when creating a reprex and seeing an empty line appearing in the console before the prompter for the next command comes up:
ℹ Rendering reprex...
✔ Reprex output is on the clipboard.
> # hexagonal spatial blocking by specified size and random assignment
> sb1 <- cv_spatial(x = pa_data,
+ column = "occ",
+ size = 4500,
+ k = 5,
+ selection = "random",
+ iteration = 50,
+ progress = FALSE,
+ report = FALSE,
+ plot = FALSE)
>
library(blockCV)
#> blockCV 3.0.0
# import presence-absence species data
points <- read.csv(system.file("extdata/", "species.csv", package = "blockCV"))
# make an sf object from data.frame
pa_data <- sf::st_as_sf(points, coords = c("x", "y"), crs = 7845)
# hexagonal spatial blocking by specified size and random assignment
sb1 <- cv_spatial(
x = pa_data,
column = "occ",
size = 4500,
k = 5,
selection = "random",
iteration = 50,
progress = FALSE,
report = FALSE
)
In https://github.com/rvalavi/blockCV/blob/master/R/cv_spatial.R#L407
This causes tests with
expect_silent()
to error as the function actually returns\n
. Thecat()
should be conditioned under thereport
block to not always print an empty line and probably also only appear within thewarning()
calls itself and not be executed standalone.You can verify this when creating a reprex and seeing an empty line appearing in the console before the prompter for the next command comes up:
Created on 2023-02-28 with reprex v2.0.2