Skip to content

Commit

Permalink
fix cran issues (#47)
Browse files Browse the repository at this point in the history
- fix cran issues
- update readme
- fix Matrix update compatibility issues
  • Loading branch information
jeffreyhanson authored Sep 14, 2022
1 parent 6197e6d commit d2bb922
Show file tree
Hide file tree
Showing 66 changed files with 637 additions and 318 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/R-CMD-check-fedora.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
on:
schedule:
- cron: 0 0 * * 1 # schedule to run at midnight on Monday each week
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

name: Fedora

jobs:
R-CMD-check:
name: Fedora (devel)

runs-on: ubuntu-latest

container:
image: docker://rhub/fedora-clang-devel:latest
options: --user root
env:
_R_REMOTES_NO_ERRORS_FROM_WARNINGS_: true
_R_CHECK_FORCE_SUGGESTS_: false
_R_CHECK_TIMINGS_: 10
_R_CHECK_CRAN_INCOMING_REMOTE_: false
_R_CHECK_LIMIT_CORES_: true
_R_CHECK_LICENSE_: true
OMP_THREAD_LIMIT: 2
KMP_DEVICE_THREAD_LIMIT: 2
KMP_TEAMS_THREAD_LIMIT: 2
KMP_ALL_THREADS: 2
NOT_CRAN: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
CI: true

steps:
- uses: actions/checkout@v2

- name: Setup path
run: |
echo "/opt/R-devel/bin" >> $GITHUB_PATH
- name: Install system dependencies
run: |
echo $PATH
dnf install -y \
mpfr-devel \
automake \
fftw-devel \
gmp-devel \
openssl-devel \
zlib-devel \
pandoc \
pandoc-citeproc \
geos-devel \
make \
gdal \
libxml2-devel \
cmake \
proj-devel \
sqlite-devel \
gdal-devel \
libicu-devel \
udunits2-devel \
coin-or-SYMPHONY-devel \
git-all
- name: Install dependencies
run: |
options(repos = "https://cloud.r-project.org/")
install.packages("remotes")
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Session information
run: |
options(width = 100)
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}

- name: Check
run: |
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran", "--no-build-vignettes"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
2 changes: 2 additions & 0 deletions .github/workflows/R-CMD-check-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
_R_CHECK_FORCE_SUGGESTS_: false
_R_CHECK_TIMINGS_: 10
_R_CHECK_CRAN_INCOMING_REMOTE_: false
_R_CHECK_LIMIT_CORES_: true
OMP_THREAD_LIMIT: 2
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
CI: true

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/R-CMD-check-ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
_R_CHECK_FORCE_SUGGESTS_: false
_R_CHECK_TIMINGS_: 10
_R_CHECK_CRAN_INCOMING_REMOTE_: false
_R_CHECK_LIMIT_CORES_: true
OMP_THREAD_LIMIT: 2
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
CI: true

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/R-CMD-check-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
_R_CHECK_FORCE_SUGGESTS_: false
_R_CHECK_TIMINGS_: 10
_R_CHECK_CRAN_INCOMING_REMOTE_: false
_R_CHECK_LIMIT_CORES_: true
OMP_THREAD_LIMIT: 2
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
CI: true

Expand Down
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: surveyvoi
Type: Package
Version: 1.0.4
Version: 1.0.5
Title: Survey Value of Information
Description: Decision support tool for prioritizing sites for ecological
surveys based on their potential to improve plans for conserving
Expand All @@ -13,7 +13,7 @@ Description: Decision support tool for prioritizing sites for ecological
algorithms. After generating such survey plans, they can be evaluated using
conditions) and maximizing value of information. Please note that several
functions depend on the 'Gurobi' optimization software (available from
<https://www.gurobi.com>). Additionally, the JAGS software (available from
<https://www.gurobi.com>). Additionally, the 'JAGS' software (available from
<https://mcmc-jags.sourceforge.io/>) is required to fit hierarchical
generalized linear models.
Authors@R: c(person(c('Jeffrey', 'O'), 'Hanson',
Expand Down Expand Up @@ -114,4 +114,5 @@ Collate:
'simulate_site_data.R'
'validate.R'
'weighted_survey_scheme.R'
'zzz.R'
Roxygen: list(markdown = TRUE)
29 changes: 19 additions & 10 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# surveyvoi 1.0.5

- CRAN release.
- Skip tests on Fedora systems because unable to reproduce error on CRAN.
- Fix compiler warning thrown during installation.
- Fix compatibility issues with upcoming _Matrix_ package (version >= 1.4-2) .
- Fix issues unloading package properly.
- Update citation information in README.

# surveyvoi 1.0.4

- CRAN release.
Expand All @@ -9,19 +18,19 @@

# surveyvoi 1.0.3.11

- Update `simulate_site_data()` function to remove RandomFields package
- Update `simulate_site_data()` function to remove _RandomFields_ package
as a dependency.

# surveyvoi 1.0.3.10

- Fix CRAN note about utils package dependency.
- Skip unit tests that require RandomFields package on Windows to avoid
- Fix CRAN note about _utils_ package dependency.
- Skip unit tests that require _RandomFields_ package on Windows to avoid
spurious failures.

# surveyvoi 1.0.3.9

- Update documentation for new code repository location.
- Add remote for RandomFields package to facilitate installation.
- Add remote for _RandomFields_ package to facilitate installation.

# surveyvoi 1.0.3.8

Expand All @@ -30,11 +39,11 @@
# surveyvoi 1.0.3.7

- Tweak package documentation.
- The RandomFields package is now an optional dependency.
- The _RandomFields_ package is now an optional dependency.

# surveyvoi 1.0.3.6

- Update README with system requirements for PoissonBinomial package (#42).
- Update README with system requirements for _PoissonBinomial_ package (#42).

# surveyvoi 1.0.3.5

Expand All @@ -54,11 +63,11 @@

# surveyvoi 1.0.3.2

- Fix compatibility issues with updates to the xgboost package (version 1.5.0).
- Fix parallel processing tests given updates to the testthat package
- Fix compatibility issues with updated _xgboost_ package (version 1.5.0).
- Fix parallel processing tests given updates to the _testthat_ package
(version 3.1.2).
- Fix tests for environmental and geographic survey schemes given updates to
the gurobi package (version 9.5.0).
the _gurobi_ package (version 9.5.0).

# surveyvoi 1.0.3.1

Expand Down Expand Up @@ -100,7 +109,7 @@
# surveyvoi 1.0.0

- Refactor for official release.
- Add support for generating surveys with the Rsymphony package.
- Add support for generating surveys with the _Rsymphony_ package.

# surveyvoi 0.0.76

Expand Down
2 changes: 1 addition & 1 deletion R/feasible_survey_schemes.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ gurobi_feasible_survey_schemes <- function(cost, budget, locked_in,
nrow = 2, ncol = length(cost), byrow = TRUE)
m <- list(
obj = rep(1, length(costs)),
A = methods::as(rcpp_feasible_actions_ilp_matrix(costs), "dgCMatrix"),
A = as_Matrix(rcpp_feasible_actions_ilp_matrix(costs), "dgCMatrix"),
sense = c(rep("=", ncol(costs)), "<="),
rhs = c(rep(1, ncol(costs)), budget),
lb = rep(0, length(costs)),
Expand Down
2 changes: 1 addition & 1 deletion R/ilp.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ weight_based_prioritizations <- function(
## create objective function
obj <- c(x)
## create constraints
A <- methods::as(matrix(costs, nrow = 1, ncol = length(x)), "dgCMatrix")
A <- as_Matrix(matrix(costs, nrow = 1, ncol = length(x)), "dgCMatrix")
## create RHS vector
rhs <- c(NA_real_)
## create sense vector
Expand Down
60 changes: 60 additions & 0 deletions R/internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,63 @@ is_jags_installed <- function() {
if (!file.exists(x)) return(FALSE)
TRUE
}

#' Convert to Matrix
#'
#' Convert an object to a matrix class provided by the \pkg{Matrix} package.
#'
#' @param object object.
#'
#' @param class `character` name of new classes.
#'
#' @details
#' This function is a wrapper that is designed to provide
#' compatibility with older and newer versions of the \pkg{Matrix} package.
#'
#' @return `Matrix` object.
#'
#' @noRd
as_Matrix <- function(object, class) {
# assert valid argument
assertthat::assert_that(
assertthat::is.string(class),
assertthat::noNA(class)
)
# if we just want to convert to generic Matrix class then do that...
if (identical(class, "Matrix")) {
return(methods::as(object, class))
}
# convert matrix
# nocov start
if (utils::packageVersion("Matrix") >= as.package_version("1.4-2")) {
if (identical(class, "dgCMatrix")) {
c1 <- "dMatrix"
c2 <- "generalMatrix"
c3 <- "CsparseMatrix"
} else if (identical(class, "dgTMatrix")) {
c1 <- "dMatrix"
c2 <- "generalMatrix"
c3 <- "TsparseMatrix"
} else if (identical(class, "dsCMatrix")) {
c1 <- "dMatrix"
c2 <- "symmetricMatrix"
c3 <- "CsparseMatrix"
} else if (identical(class, "dsTMatrix")) {
c1 <- "dMatrix"
c2 <- "symmetricMatrix"
c3 <- "TsparseMatrix"
} else if (identical(class, "lgCMatrix")) {
c1 <- "lMatrix"
c2 <- "generalMatrix"
c3 <- "CsparseMatrix"
} else {
stop("argument to \"class\" not recognized")
}
out <- methods::as(methods::as(methods::as(object, c1), c2), c3)
} else {
out <- methods::as(object, class)
}
# nocov end
# return result
out
}
3 changes: 3 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.onUnload <- function(libpath) {
library.dynam.unload("surveyvoi", libpath)
}
Loading

0 comments on commit d2bb922

Please sign in to comment.