diff --git a/DESCRIPTION b/DESCRIPTION index a9284e5a..d82e9d10 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: rSFSW2 Title: Simulation Framework for SOILWAT2 -Version: 3.1.4 +Version: 3.1.5 Date: 2019-03-14 Authors@R: c( person("Daniel", "Schlaepfer", email = "daniel.schlaepfer@yale.edu", @@ -57,6 +57,7 @@ NeedsCompilation: yes License: GPL-3 + file LICENSE URL: https://github.com/DrylandEcology/rSFSW2 BugReports: https://github.com/DrylandEcology/rSFSW2/issues -RoxygenNote: 6.1.0 +RoxygenNote: 6.1.1 VignetteBuilder: knitr Language: en-US +Encoding: UTF-8 diff --git a/R/ExtractData_ClimateDownscaling.R b/R/ExtractData_ClimateDownscaling.R index bf119255..107297e9 100644 --- a/R/ExtractData_ClimateDownscaling.R +++ b/R/ExtractData_ClimateDownscaling.R @@ -1175,7 +1175,7 @@ doQmapQUANT.default_drs <- function(x, fobj, type = NULL, lin_extrapol = NULL, } } else if (identical(type, "tricub")) { sfun <- stats::splinefun(x = fobj[["par"]]$modq[, 1], y = fobj[["par"]]$fitq[, 1], - method = spline_method) + method = spline_method, ties = mean) temp <- sfun(x[wet]) if (!is.null(monthly_extremes) && !identical(fix_spline, "none")) { @@ -1188,7 +1188,8 @@ doQmapQUANT.default_drs <- function(x, fobj, type = NULL, lin_extrapol = NULL, stop("Out-of-range splinefun values and 'fix_spline' set to fail") } sfun <- stats::splinefun(x = jitter(fobj[["par"]]$modq[, 1]), - y = jitter(fobj[["par"]]$fitq[, 1]), method = spline_method) + y = jitter(fobj[["par"]]$fitq[, 1]), method = spline_method, + ties = mean) temp <- sfun(x[wet]) icount <- icount + 1 } diff --git a/R/Mathematical_Functions.R b/R/Mathematical_Functions.R index dd6f3c20..a5d94787 100644 --- a/R/Mathematical_Functions.R +++ b/R/Mathematical_Functions.R @@ -253,8 +253,8 @@ whereNearest <- function(val, matrix) { #' @return A logical value. is.natural <- function(x) { typeof(x) %in% c("integer", "double", "complex") && - !is.null(x) && length(x) > 0 && !is.na(x) && - isTRUE(all.equal(x, round(x))) && x > 0 + !is.null(x) && length(x) > 0 && !anyNA(x) && + isTRUE(all.equal(x, round(x))) && all(x > 0) } #' The intersection on any number of vectors @@ -382,9 +382,8 @@ check_monotonic_increase <- function(x, MARGIN = 1, increase = TRUE, } ord <- !match.fun(mfun)(x[, -1, drop = FALSE], x[, -ncol(x), drop = FALSE]) - has_na <- is.na(x) - if (any(ord, na.rm = TRUE) || (has_na && !na.rm && strictly)) { + if ((!na.rm && strictly && anyNA(x)) || any(ord, na.rm = TRUE)) { if (fail) { stop(paste0("'check_monotonic_increase': data are not ", if (strictly) "strictly ", "monotonically ", diff --git a/README.md b/README.md index 86a33ba9..e89c7104 100644 --- a/README.md +++ b/README.md @@ -195,9 +195,14 @@ You can contribute to this project in different ways: [Wickham's book 'R packages'](http://r-pkgs.had.co.nz/man.html) * Use [roxygen2](https://CRAN.R-project.org/package=roxygen2/vignettes/formatting.html) to write inline code documentation - * Update help pages and NAMESPACE with the command `devtools::document()` + * Update help pages and NAMESPACE with the command `devtools::document()`; + note: you may need to compile dynamic libraries first with + `pkgbuild::compile_dll()`. * Ideally, add examples to function documentation and check these examples - with the command `devtools::run_examples()` + with the command `devtools::run_examples()`. + Note: "devtools" v2.0.1 mixed up the logic for "dontrun" examples (see + https://github.com/r-lib/devtools/issues/2003); until this is fixed, + use `devtools::run_examples(run = FALSE)`. * Ideally, expand and/or add vignettes. @@ -268,6 +273,7 @@ You can contribute to this project in different ways: 1. Make sure that the documentation is up-to-date with: ```{r} + pkgbuild::compile_dll() devtools::document() ``` @@ -275,6 +281,9 @@ You can contribute to this project in different ways: ```{r} devtools::run_examples() ``` + Note: "devtools" v2.0.1 mixed up the logic for "dontrun" examples (see + https://github.com/r-lib/devtools/issues/2003); until this is fixed, + use `devtools::run_examples(run = FALSE)`. 1. Run tests as if not on CRAN, in an interactive R session, and with a sequential schedule. diff --git a/tests/testthat/test_Mathematical_Functions.R b/tests/testthat/test_Mathematical_Functions.R index 9b3122c8..51ab73b0 100644 --- a/tests/testthat/test_Mathematical_Functions.R +++ b/tests/testthat/test_Mathematical_Functions.R @@ -42,10 +42,15 @@ test_that("Monotonicity:", { x } good_strict_matrices[["x4"]] <- { - x <- test_matrices[["x4"]] - x[2, 3] <- replacement - x - } + x <- test_matrices[["x4"]] + x[2, 3] <- replacement + x + } + good_strict_matrices[["x5"]] <- { + x <- test_matrices[["x5"]] + x[2, 2:3] <- replacement + x + } good_strict_matrices[["x6"]] <- { x <- test_matrices[["x6"]] x[2, 3] <- replacement diff --git a/tests/testthat/test_rSFSW2_CodeStylePractices.R b/tests/testthat/test_rSFSW2_CodeStylePractices.R index 0fc61717..06fbef8f 100644 --- a/tests/testthat/test_rSFSW2_CodeStylePractices.R +++ b/tests/testthat/test_rSFSW2_CodeStylePractices.R @@ -17,6 +17,11 @@ test_that("Package code style", { skip("Installed version of lintr is insufficient.") } + # as of 2019-03-11 `lintr` fails R-devel `_R_CHECK_LENGTH_1_LOGIC2_`, see + # https://github.com/jimhester/lintr/issues/377 (undo once this is fixed) + rctemp <- Sys.getenv("_R_CHECK_LENGTH_1_LOGIC2_") + Sys.setenv(`_R_CHECK_LENGTH_1_LOGIC2_` = "false") + # Files that are not checked for lints files_not_tolint <- c( "ExtractData_ClimateDownscaling.R", # needs linting @@ -57,6 +62,9 @@ test_that("Package code style", { expect_identical(length(badstyle), 0L, info = print(badstyle)) } } + + # reset + Sys.setenv(`_R_CHECK_LENGTH_1_LOGIC2_` = rctemp) })