Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 22 additions & 64 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# 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

permissions: read-all

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
Expand All @@ -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")'
13 changes: 7 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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", comment = c(ORCID="0000-0002-4565-533X")))
Maintainer: Pierre Roudier <roudierp@landcareresearch.co.nz>
URL: https://github.com/pierreroudier/clhs/
BugReports: https://github.com/pierreroudier/clhs/issues
Expand All @@ -19,7 +20,6 @@ Imports: utils,
methods,
grid,
ggplot2,
sp,
sf,
raster,
reshape2,
Expand All @@ -30,11 +30,12 @@ LinkingTo: RcppArmadillo, Rcpp
License: GPL (>= 2)
Encoding: UTF-8
LazyLoad: yes
Suggests: knitr,
Suggests: sp,
knitr,
rmarkdown,
testthat
VignetteBuilder: knitr
RoxygenNote: 7.1.2
RoxygenNote: 7.3.2
Collate:
'RcppExports.R'
'clhs-internal.R'
Expand Down
40 changes: 20 additions & 20 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- NEWS.md is maintained by https://cynkra.github.io/fledge, do not edit -->

- 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!)

Expand All @@ -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:
Expand All @@ -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.
4 changes: 2 additions & 2 deletions R/clhs-data.frame.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion R/clhs-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#' @import Rcpp
#' @useDynLib clhs
#'
NULL
"_PACKAGE"

#' Conditioned Latin Hypercube Sampling result
#'
Expand Down
2 changes: 1 addition & 1 deletion R/clhs-sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
Expand Down
6 changes: 3 additions & 3 deletions R/similarity.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
#'
#' @export
#'
#' @examples
#' @examplesIf requireNamespace("sp")
#' library(raster)
#' 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)
#'
Expand Down Expand Up @@ -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
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
5 changes: 3 additions & 2 deletions man/similarity_buffer.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion src/Makevars.win
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 3 additions & 1 deletion tests/testthat/test-clhs-gower.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
context("clhs-gower")

test_that("Gower similarity works", {


skip_if_not_installed("sp")

library(raster)
library(sp)

Expand Down
4 changes: 3 additions & 1 deletion tests/testthat/test-spdf.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -16,7 +18,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)
Expand Down