From 434e397066c55d46a29f58c8b0f339331b336bd3 Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Wed, 30 Apr 2025 06:49:58 -0700 Subject: [PATCH 01/13] drop C++11 specification (non-essential) --- src/Makevars | 2 +- src/Makevars.win | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makevars b/src/Makevars index d3e3f41..e578f48 100644 --- a/src/Makevars +++ b/src/Makevars @@ -8,7 +8,7 @@ ## ## And with R 3.4.0, and RcppArmadillo 0.7.960.*, we turn C++11 on as OpenMP ## support within Armadillo prefers / requires it -CXX_STD = CXX11 +# CXX_STD = CXX11 PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) diff --git a/src/Makevars.win b/src/Makevars.win index d3e3f41..e578f48 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -8,7 +8,7 @@ ## ## And with R 3.4.0, and RcppArmadillo 0.7.960.*, we turn C++11 on as OpenMP ## support within Armadillo prefers / requires it -CXX_STD = CXX11 +# CXX_STD = CXX11 PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) From 8e8fbae8ae79670b5a505f17bb450b2d469b184c Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Wed, 30 Apr 2025 06:51:39 -0700 Subject: [PATCH 02/13] Update NEWS.md - fix version parsing for old news entries for CRAN check - spelling --- NEWS.md | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/NEWS.md b/NEWS.md index bdd1c02..19b30ff 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,7 @@ - Fixed slow example in the plot docs -- fixed the way RcppAramadillo dependecny is handled so to pass CRAN tests +- fixed the way RcppArmadillo dependency is handled so to pass CRAN tests - added Rcpp and RcppArmadillo dependencies - Added C++ implementation (much faster!) @@ -24,37 +24,37 @@ - Implemented an improved logic to drop worse sample (thanks to David Clifford) - Various minor bug fixes to support R > 4.0 -# clhs_0.7-2 +# clhs 0.7-2 - Maintenance version fixing new RNG sampler call. -# clhs_0.7-0 +# clhs 0.7-0 - New DLHS method contributed by Benjamin Louis - Included possibility to include compulsory/existing samples in the set (thanks to Benjamin Louis) - Added more tests -# clhs_0.6-0 +# clhs 0.6-0 - Added Gower similarity tool (thanks to Colby Brugnard) - Switched documentation to Roxygen - Implemented the first few tests -# clhs_0.5-7 +# clhs 0.5-7 - fixed sneaky bug that produced duplicated sampling points (thanks Ankur Gupta for the pointers) -# clhs_0.5-6 +# clhs 0.5-6 - fixed bug when passing a single raster layer (Github issue #1, thanks Github user GreatEmerald) - Raster* clhs method now returns SpatialPointsDataFrame -# clhs_0.5-3 +# clhs 0.5-3 - corrected dependencies - now depend on R >= 2.14 (due to ggplot2) -# clhs_0.5-2 +# clhs 0.5-2 - version ready for release when ggplot2_0.9.2.1 is rolled out -# clhs_0.5-1 +# clhs 0.5-1 - minor bugfix version fixing compatibility issues with ggplot2 >= 0.9.2 - added ggplot2 in Suggests temporary to fix bug in ggplot2_0.9.2 -# clhs_0.5-0 +# clhs 0.5-0 - introduced cost and cost tracking modes - general code cleaning - improved plot function: @@ -64,40 +64,40 @@ - new boxplot mode - cleaner NAMESPACE -# clhs_0.4-3 +# clhs 0.4-3 - Dummy version increment to solve CRAN upload problems -# clhs_0.4-2 +# clhs 0.4-2 - Added the choice between histogram and density plots in the plot method -# clhs_0.4-1 +# clhs 0.4-1 - Improved doc - Complete plot.cLHS_result method using ggplot2 - new reshape2 dependency - various buxfixes, esp. for spatial classes -# clhs_0.4-0 +# clhs 0.4-0 - Introduced cLHS_result S3 class with associated plot method - Introduced simple = ... option to the clhs() method. If set to true, returns only the indices of the selected samples, if set to FALSE, returns a cLHS_result object (eg if you want to plot the objective function behaviour). - added a plot() method. For the moment, it just plots the objective function. -# clhs_0.3-2 +# clhs 0.3-2 - slight improvement on the Raster method using rasterToPoints(...) - added plotting option for the objective function -# clhs_0.3-1 +# clhs 0.3-1 - Corrected bug on Raster* methods. Now returns a SpatialPointsDataFrame object. -# clhs_0.3-0 +# clhs 0.3-0 - Switch to S4 methods - Introduced methods for Raster* and SpatialP*DataFrame classes -# clhs_0.2-1 +# clhs 0.2-1 - changed examples -# clhs_0.2-0 +# clhs 0.2-0 - Fixed important bugs in the annealing process. -# clhs_0.1-0 +# clhs 0.1-0 - Initial release of the package. From 4a9b3c723b4c057632166d55ff241656392f99a8 Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Wed, 30 Apr 2025 06:53:18 -0700 Subject: [PATCH 03/13] move sp to suggests --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c628471..e72cf3d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,7 +19,6 @@ Imports: utils, methods, grid, ggplot2, - sp, sf, raster, reshape2, @@ -30,7 +29,8 @@ LinkingTo: RcppArmadillo, Rcpp License: GPL (>= 2) Encoding: UTF-8 LazyLoad: yes -Suggests: knitr, +Suggests: sp, + knitr, rmarkdown, testthat VignetteBuilder: knitr From 59f64375944275d83d111045c56d035d82919e5e Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Wed, 30 Apr 2025 07:04:17 -0700 Subject: [PATCH 04/13] Update R-CMD-check.yaml --- .github/workflows/R-CMD-check.yaml | 88 ++++++++---------------------- README.md | 2 +- 2 files changed, 24 insertions(+), 66 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 81eb114..562fe0f 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,16 +1,13 @@ -# 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 +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: - - main - - master + branches: [main, master] pull_request: - branches: - - main - - master -name: R-CMD-check +name: R-CMD-check.yaml + +permissions: read-all jobs: R-CMD-check: @@ -22,72 +19,33 @@ jobs: fail-fast: false matrix: config: + - {os: macos-latest, r: 'release'} - {os: windows-latest, r: 'release'} - - {os: macOS-latest, r: 'release'} - - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} env: - R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - RSPM: ${{ matrix.config.rspm }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true - - uses: r-lib/actions/setup-pandoc@v1 - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Restore R package cache - if: runner.os != 'Windows' - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install system dependencies - if: runner.os == 'Linux' - run: | - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') - - - name: "[Custom block] [macOS] Install spatial libraries" - if: runner.os == 'macOS' - run: | - # conflicts with gfortran from r-lib/actions when linking gcc - # rm '/usr/local/bin/gfortran' - brew install pkg-config gdal proj geos - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("rcmdcheck") - shell: Rscript {0} - - - name: Check - env: - _R_CHECK_CRAN_INCOMING_REMOTE_: false - run: | - options(crayon.enabled = TRUE) - rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") - shell: Rscript {0} + extra-packages: any::rcmdcheck + needs: check - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main + - uses: r-lib/actions/check-r-package@v2 with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/README.md b/README.md index dbbd868..f79a91c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![R build status](https://github.com/pierreroudier/clhs/workflows/R-CMD-check/badge.svg)](https://github.com/pierreroudier/clhs/actions) +[![R-CMD-check](https://github.com/pierreroudier/clhs/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/pierreroudier/clhs/actions/workflows/R-CMD-check.yaml) [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/clhs)](https://cran.r-project.org/package=clhs) [![Total_Downloads](http://cranlogs.r-pkg.org/badges/grand-total/clhs)](https://cran.r-project.org/package=clhs) From bf62c489f395789043772246b04f1afa53e9e3fb Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Wed, 30 Apr 2025 07:22:56 -0700 Subject: [PATCH 05/13] roxygen update --- DESCRIPTION | 2 +- R/clhs-package.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e72cf3d..fa00297 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -34,7 +34,7 @@ Suggests: sp, rmarkdown, testthat VignetteBuilder: knitr -RoxygenNote: 7.1.2 +RoxygenNote: 7.3.2 Collate: 'RcppExports.R' 'clhs-internal.R' diff --git a/R/clhs-package.R b/R/clhs-package.R index e99732e..81c0927 100644 --- a/R/clhs-package.R +++ b/R/clhs-package.R @@ -45,7 +45,7 @@ #' @import Rcpp #' @useDynLib clhs #' -NULL +"_PACKAGE" #' Conditioned Latin Hypercube Sampling result #' From c78e1a31d50abd1828cee8fc7cc1d4d16594d6dd Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Wed, 30 Apr 2025 07:42:08 -0700 Subject: [PATCH 06/13] fix typo --- R/clhs-sf.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/clhs-sf.R b/R/clhs-sf.R index 5b13c6c..d56fb69 100644 --- a/R/clhs-sf.R +++ b/R/clhs-sf.R @@ -17,7 +17,7 @@ clhs.sf <- function( # When coords are used only points/multipoints are supported if (! st_geometry_type(x, by_geometry = FALSE) %in% c("POINT", "MULTIPOINT")) { stop( - "When use.coords` is set to TRUE, only POINT/MULTIPOINT geometries are supported.", + "When `use.coords` is set to TRUE, only POINT/MULTIPOINT geometries are supported.", call. = FALSE ) } From 2593a003a15dbdd2d1492ae4905a2d791ff30311 Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Wed, 30 Apr 2025 07:43:23 -0700 Subject: [PATCH 07/13] fix error "Not a matrix" with 1 column and `use.cpp=TRUE` default --- R/clhs-data.frame.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/clhs-data.frame.R b/R/clhs-data.frame.R index 320b149..911bbd6 100644 --- a/R/clhs-data.frame.R +++ b/R/clhs-data.frame.R @@ -113,11 +113,11 @@ clhs.data.frame <- function( if(is.null(include)){ dat <- data - inc <- dat[0,] + inc <- dat[0, , drop = FALSE] # keep as matrix if just one column ssize <- size } else{ dat <- data[-include,] - inc <- data[include,,drop = FALSE] ##keep as matrix if just one row + inc <- data[include, , drop = FALSE] # keep as matrix if just one row ssize <- size - length(include) can.include <- 1:nrow(dat) } From 5f927902c9fe68f9f79b61abfac5109115fa6cee Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Wed, 30 Apr 2025 08:28:17 -0700 Subject: [PATCH 08/13] avoid `"+init="` proj4 style warnings for CRS --- R/similarity.R | 4 ++-- man/similarity_buffer.Rd | 2 +- tests/testthat/test-spdf.R | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/similarity.R b/R/similarity.R index 3a106a2..160e04e 100644 --- a/R/similarity.R +++ b/R/similarity.R @@ -30,7 +30,7 @@ #' #' data(meuse.grid) #' coordinates(meuse.grid) = ~x+y -#' proj4string(meuse.grid) <- CRS("+init=epsg:28992") +#' proj4string(meuse.grid) <- CRS("EPSG:28992") #' gridded(meuse.grid) = TRUE #' ms <- stack(meuse.grid) #' @@ -100,4 +100,4 @@ similarity_buffer <- function(covs, pts, buffer, fac = NA, metric = "gower", sta names(res_s) <- paste0('similarity_point_', 1:nlayers(res_s)) res_s -} \ No newline at end of file +} diff --git a/man/similarity_buffer.Rd b/man/similarity_buffer.Rd index 45c5295..ea7e5a3 100644 --- a/man/similarity_buffer.Rd +++ b/man/similarity_buffer.Rd @@ -41,7 +41,7 @@ library(sp) data(meuse.grid) coordinates(meuse.grid) = ~x+y -proj4string(meuse.grid) <- CRS("+init=epsg:28992") +proj4string(meuse.grid) <- CRS("EPSG:28992") gridded(meuse.grid) = TRUE ms <- stack(meuse.grid) diff --git a/tests/testthat/test-spdf.R b/tests/testthat/test-spdf.R index 1c3f49c..d4acd09 100644 --- a/tests/testthat/test-spdf.R +++ b/tests/testthat/test-spdf.R @@ -16,7 +16,7 @@ test_that("clhs on a SpatialPointsDataFrame works", { spdf <- sp::SpatialPointsDataFrame( coords = df[, c("x", "y")], data = df[, c("a", "b", "c")], - proj4string = sp::CRS("+init=epsg:4326") + proj4string = sp::CRS("EPSG:4326") ) res1 <- clhs(spdf, size = 5, iter = 100, progress = FALSE, simple = TRUE) From e2a230eadfb0673a3e87c36eb492210b244acad7 Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Thu, 1 May 2025 07:32:58 -0700 Subject: [PATCH 09/13] update test and examples for sp in suggests --- R/similarity.R | 2 +- man/similarity_buffer.Rd | 3 ++- tests/testthat/test-spdf.R | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/R/similarity.R b/R/similarity.R index 160e04e..834a02e 100644 --- a/R/similarity.R +++ b/R/similarity.R @@ -24,7 +24,7 @@ #' #' @export #' -#' @examples +#' @examplesIf requireNamespace("sp") #' library(raster) #' library(sp) #' diff --git a/man/similarity_buffer.Rd b/man/similarity_buffer.Rd index ea7e5a3..7b03818 100644 --- a/man/similarity_buffer.Rd +++ b/man/similarity_buffer.Rd @@ -36,6 +36,7 @@ a RasterStack Calculates Gower's similarity index for every pixel within an given radius buffer of each sampling point } \examples{ +\dontshow{if (requireNamespace("sp") ) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} library(raster) library(sp) @@ -50,7 +51,7 @@ set.seed(1) pts <- clhs(ms, size = 3, iter = 100, progress = FALSE, simple = FALSE) gw <- similarity_buffer(ms, pts$sampled_data, buffer = 500) plot(gw) - +\dontshow{\}) # examplesIf} } \references{ Brungard, C. and Johanson, J. 2015. The gate's locked! I can't get to the exact diff --git a/tests/testthat/test-spdf.R b/tests/testthat/test-spdf.R index d4acd09..f29aae9 100644 --- a/tests/testthat/test-spdf.R +++ b/tests/testthat/test-spdf.R @@ -2,6 +2,8 @@ context("clhs-sp") test_that("clhs on a SpatialPointsDataFrame works", { + skip_if_not_installed("sp") + suppressWarnings(RNGversion("3.5.0")) set.seed(1) From 5045000120290404adeedc23618d3c062213dc5f Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Thu, 1 May 2025 07:50:22 -0700 Subject: [PATCH 10/13] skip gower similarity test if sp is not installed --- tests/testthat/test-clhs-gower.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-clhs-gower.R b/tests/testthat/test-clhs-gower.R index 18efe52..aa0bf9d 100644 --- a/tests/testthat/test-clhs-gower.R +++ b/tests/testthat/test-clhs-gower.R @@ -1,7 +1,9 @@ context("clhs-gower") test_that("Gower similarity works", { - + + skip_if_not_installed("sp") + library(raster) library(sp) From 071d70395709957ca0c72caf6d63ee876e12a065 Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Thu, 29 May 2025 20:13:59 -0700 Subject: [PATCH 11/13] Update DESCRIPTION --- DESCRIPTION | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index fa00297..968e243 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,15 +1,16 @@ Package: clhs Type: Package Title: Conditioned Latin Hypercube Sampling -Version: 0.9.0 -Date: 2021-10-14 +Version: 0.9.1 +Date: 2025-05-29 Authors@R: c( person("Pierre", "Roudier", email = "roudierp@landcareresearch.co.nz", role = c("aut", "cre")), person("Colby", "Brugnard", email = "cbrung@ad.nmsu.edu", role = "ctb"), person("Dylan", "Beaudette", email = "dylan.beaudette@ca.usda.gov", role = "ctb"), person("Benjamin", "Louis", email = "contact@benjaminlouis-stat.fr", role = "ctb"), person("Kiri", "Daust", email = "Kiri.Daust@gov.bc.ca", role = "ctb"), - person("David", "Clifford", email = "david.clifford@gmail.com", role = "ctb")) + person("David", "Clifford", email = "david.clifford@gmail.com", role = "ctb"), + person("Andrew", "Brown", email = "andrew.g.brown@usda.gov", role = "ctb")) Maintainer: Pierre Roudier URL: https://github.com/pierreroudier/clhs/ BugReports: https://github.com/pierreroudier/clhs/issues From 8542dc4510a5a20b22fad7d5152f4d487db84962 Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Thu, 29 May 2025 20:19:12 -0700 Subject: [PATCH 12/13] Update DESCRIPTION --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 968e243..fb40cf1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -10,7 +10,7 @@ Authors@R: c( person("Benjamin", "Louis", email = "contact@benjaminlouis-stat.fr", role = "ctb"), person("Kiri", "Daust", email = "Kiri.Daust@gov.bc.ca", role = "ctb"), person("David", "Clifford", email = "david.clifford@gmail.com", role = "ctb"), - person("Andrew", "Brown", email = "andrew.g.brown@usda.gov", role = "ctb")) + person("Andrew", "Brown", email = "andrew.g.brown@usda.gov", role = "ctb", comment = c(ORCID="0000-0002-4565-533X"))) Maintainer: Pierre Roudier URL: https://github.com/pierreroudier/clhs/ BugReports: https://github.com/pierreroudier/clhs/issues From 38f3c37078ecde678eeee5d36b7323aec96814e8 Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Thu, 29 May 2025 20:24:13 -0700 Subject: [PATCH 13/13] Update .github/workflows/R-CMD-check.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 562fe0f..1dc2cbd 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -5,7 +5,7 @@ on: branches: [main, master] pull_request: -name: R-CMD-check.yaml +name: R-CMD-check permissions: read-all