Skip to content

Commit

Permalink
Merge pull request #363 from DrylandEcology/bugfix_external_API_changes
Browse files Browse the repository at this point in the history
Addressing changes in interfaces of dependencies:
- roxygen2 v6.1.1
- devtools v2.0.1
- R-devel (upcoming v3.6.0)
- lintr (incompatible with R-devel)
  • Loading branch information
dschlaep committed Mar 15, 2019
2 parents e43dc87 + ba0e5c4 commit 1a28723
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 14 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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
5 changes: 3 additions & 2 deletions R/ExtractData_ClimateDownscaling.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand All @@ -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
}
Expand Down
7 changes: 3 additions & 4 deletions R/Mathematical_Functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ",
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down Expand Up @@ -268,13 +273,17 @@ 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()
```

1. Run and check the code from the examples and vignettes:
```{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.
Expand Down
13 changes: 9 additions & 4 deletions tests/testthat/test_Mathematical_Functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test_rSFSW2_CodeStylePractices.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
})


Expand Down

0 comments on commit 1a28723

Please sign in to comment.