diff --git a/R/cache.R b/R/cache.R index 89797c259..6cb610b19 100644 --- a/R/cache.R +++ b/R/cache.R @@ -1045,7 +1045,7 @@ Cache <- #' @keywords internal .namesPostProcessFormals <- function() { c( - "x", "filename1", "filename2", "studyArea", "rasterToMatch", + "x", "filename1", "writeTo", "studyArea", "rasterToMatch", "overwrite", "useSAcrs", "useCache", "verbose" ) } diff --git a/R/postProcessTo.R b/R/postProcessTo.R index a8523ca5d..c8545add8 100644 --- a/R/postProcessTo.R +++ b/R/postProcessTo.R @@ -1273,6 +1273,11 @@ remapOldArgs <- function(..., fn = sys.function(sys.parent()), envir = parent.fr verbose = getOption("reproducible.verbose")) { forms <- formals(fn) dots <- list(...) + + if (!is.null(dots$filename2)) { + stop("filename2 arg is deprecated - please pass 'writeTo' instead (see `reproducible::writeTo`") + } + dots <- dots[!vapply(dots, is.null, FUN.VALUE = logical(1))] ret <- list() diff --git a/R/preProcess.R b/R/preProcess.R index 46df0b30a..7af664890 100644 --- a/R/preProcess.R +++ b/R/preProcess.R @@ -1,5 +1,6 @@ utils::globalVariables(c( - "reproducible.inputPaths", "successfulCheckSumFilePath", "successfulDir" + "reproducible.inputPaths", "successfulCheckSumFilePath", "successfulDir", + "destinationPathUser" )) #' @param n Number of non-null arguments passed to `preProcess`. diff --git a/R/prepInputs.R b/R/prepInputs.R index 87f58f29e..4769cc5a2 100644 --- a/R/prepInputs.R +++ b/R/prepInputs.R @@ -45,8 +45,7 @@ utils::globalVariables(c( #' \item Crop using [cropTo()]; #' \item Project using [projectTo()]; #' \item Mask using [maskTo()]; -#' \item Determine file name [determineFilename()] via `filename2`; -#' \item Optionally, write that file name to disk via [writeTo()]. +#' \item write the file to disk via [writeTo()]. #' } #' #' NOTE: checksumming does not occur during the post-processing stage, as @@ -311,7 +310,7 @@ utils::globalVariables(c( #' studyArea = studyArea, #' fun = "terra::vect", #' destinationPath = dPath, -#' filename2 = "EcozoneFile.shp" +#' writeTo = "EcozoneFile.shp" #' ) # passed to determineFilename #' #' terra::plot(shpEcozone[, 1]) diff --git a/man/prepInputs.Rd b/man/prepInputs.Rd index 23b450897..9c7c72cc3 100644 --- a/man/prepInputs.Rd +++ b/man/prepInputs.Rd @@ -332,7 +332,7 @@ if (requireNamespace("terra", quietly = TRUE) && studyArea = studyArea, fun = "terra::vect", destinationPath = dPath, - filename2 = "EcozoneFile.shp" + writeTo = "EcozoneFile.shp" ) # passed to determineFilename terra::plot(shpEcozone[, 1]) diff --git a/tests/testthat/test-cache.R b/tests/testthat/test-cache.R index 699a04c39..7c9988946 100644 --- a/tests/testthat/test-cache.R +++ b/tests/testthat/test-cache.R @@ -1717,7 +1717,7 @@ test_that("Issue 316 - writeOutputs in a non getwd dir", { rasterToMatchLarge <- list() for (i in 1:2) { rasterToMatchLarge[[i]] <- Cache(writeOutputs, rasterToMatch, - filename2 = .suffix( + writeTo = .suffix( file.path(tmpdir, "rasterToMatchLarge.tif"), paste0("_", studyAreaName) ), datatype = "INT2U", diff --git a/tests/testthat/test-prepInputs.R b/tests/testthat/test-prepInputs.R index fae60c157..2bb6486ca 100644 --- a/tests/testthat/test-prepInputs.R +++ b/tests/testthat/test-prepInputs.R @@ -95,7 +95,7 @@ test_that("prepInputs doesn't work (part 1)", { alsoExtract = reproducible::asPath(ecozoneFiles), studyArea = StudyArea, destinationPath = dPath, - filename2 = "EcozoneFile.shp", + writeTo = "EcozoneFile.shp", useCache = FALSE ), quick = "destinationPath" @@ -1866,7 +1866,7 @@ test_that("writeOutputs saves factor rasters with .grd class to preserve levels" tifTmp <- normPath(tifTmp) b1 <- suppressWarnings(terra::writeRaster(a, filename = tifTmp, overwrite = TRUE)) # the GDAL>6 issue - b1a <- writeOutputs(a, filename2 = tifTmp) + b1a <- writeOutputs(a, writeTo = tifTmp) expect_equivalent(b1, b1a) expect_equivalent(b1[], b1a[]) @@ -1903,7 +1903,7 @@ test_that("rasters aren't properly resampled", { targetFile = tiftemp1, rasterToMatch = terra::rast(tiftemp2), destinationPath = dirname(tiftemp1), method = "bilinear", datatype = "INT2S", - filename2 = tempfile(tmpdir = tmpdir, fileext = ".tif") + writeTo = tempfile(tmpdir = tmpdir, fileext = ".tif") ) }) # about "raster layer has integer values" @@ -1919,7 +1919,7 @@ test_that("rasters aren't properly resampled", { out3 <- prepInputs( targetFile = tiftemp3, rasterToMatch = terra::rast(tiftemp2), destinationPath = dirname(tiftemp3), - filename2 = tempfile(tmpdir = tmpdir, fileext = ".tif") + writeTo = tempfile(tmpdir = tmpdir, fileext = ".tif") ) expect_true(dataType2(out3) == "FLT4S") @@ -1934,7 +1934,7 @@ test_that("rasters aren't properly resampled", { out3 <- prepInputs( targetFile = tiftemp4, rasterToMatch = terra::rast(tiftemp2), destinationPath = dirname(tiftemp3), - filename2 = tempfile(tmpdir = tmpdir, fileext = ".tif") + writeTo = tempfile(tmpdir = tmpdir, fileext = ".tif") ) expect_true(is(out3, rasterType())) expect_true(identical(length(Filenames(out3)), 1L)) @@ -1947,7 +1947,7 @@ test_that("rasters aren't properly resampled", { targetFile = tiftemp4, rasterToMatch = terra::rast(tiftemp2), destinationPath = dirname(tiftemp3), fun = rasterStackFn, - filename2 = c( + writeTo = c( tempfile(tmpdir = tmpdir, fileext = ".grd"), tempfile(tmpdir = tmpdir, fileext = ".grd") ) @@ -1971,7 +1971,7 @@ test_that("rasters aren't properly resampled", { targetFile = tiftemp5, rasterToMatch = terra::rast(tiftemp2), destinationPath = dirname(tiftemp3), fun = rasterStackFn, - filename2 = c( + writeTo = c( tempfile(tmpdir = tmpdir, fileext = ".grd"), tempfile(tmpdir = tmpdir, fileext = ".grd"), tempfile(tmpdir = tmpdir, fileext = ".tif") @@ -1987,7 +1987,7 @@ test_that("rasters aren't properly resampled", { targetFile = tiftemp4, rasterToMatch = terra::rast(tiftemp2), destinationPath = dirname(tiftemp3), fun = rasterStackFn, - filename2 = c( + writeTo = c( tempfile(tmpdir = tmpdir, fileext = ".grd"), tempfile(tmpdir = tmpdir, fileext = ".grd") )