From c9902a90909c4d97359d16cfce683d1dc5b037b5 Mon Sep 17 00:00:00 2001 From: mhesselbarth Date: Fri, 14 Feb 2025 10:18:14 +0100 Subject: [PATCH] Fixing pkgkdown and some other warnings #110 --- .github/workflows/Deploy-pkgdown.yaml | 6 ++---- CRAN-RELEASE | 2 -- DESCRIPTION | 8 +++++--- NLMR.Rproj | 1 + R/nlm_mpd.R | 18 +++++++++--------- R/nlm_percolation.R | 6 +++--- README.Rmd | 6 ++---- _pkgdown.yml | 2 ++ man/nlm_mpd.Rd | 14 +++++++------- man/nlm_percolation.Rd | 6 +++--- tests/testthat.R | 16 ++++++++++++---- tests/testthat/setup.R | 3 +++ 12 files changed, 49 insertions(+), 39 deletions(-) delete mode 100644 CRAN-RELEASE create mode 100644 tests/testthat/setup.R diff --git a/.github/workflows/Deploy-pkgdown.yaml b/.github/workflows/Deploy-pkgdown.yaml index b6b07b3..0c145ff 100644 --- a/.github/workflows/Deploy-pkgdown.yaml +++ b/.github/workflows/Deploy-pkgdown.yaml @@ -32,10 +32,8 @@ jobs: - name: Install additional package dependencies run: | - repos.orig <- getOption('repos') - options(repos = c(PE = "https://predictiveecology.r-universe.dev")) ## TODO: use ropensci universe - pak::pkg_install("RandomFields") - options(repos = repos.orig) + pak::pkg_install("cran/RandomFieldsUtils") + pak::pkg_install("cran/RandomFields") shell: Rscript {0} - name: Build site diff --git a/CRAN-RELEASE b/CRAN-RELEASE deleted file mode 100644 index 5c335cf..0000000 --- a/CRAN-RELEASE +++ /dev/null @@ -1,2 +0,0 @@ -This package was submitted to CRAN on 2021-09-17. -Once it is accepted, delete this file and tag the release (commit 360d5fb). diff --git a/DESCRIPTION b/DESCRIPTION index 2feeb5f..e8ff397 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -34,7 +34,7 @@ License: GPL-3 URL: https://ropensci.github.io/NLMR/ BugReports: https://github.com/ropensci/NLMR/issues/ Depends: - R (>= 3.1.0) + R (>= 3.6) Imports: checkmate, dplyr, @@ -49,6 +49,7 @@ Imports: Suggests: ggplot2, highcharter, + igraph, knitr, kableExtra, landscapemetrics, @@ -63,7 +64,7 @@ Suggests: rayshader, rgl, rmarkdown, - testthat, + testthat (>= 3.0.0), viridis LinkingTo: Rcpp @@ -76,5 +77,6 @@ Config/Needs/website: bindrcpp, igraph, landscapemetrics, rasterVis, pals, Encoding: UTF-8 LazyData: true Roxygen: list(roclets = c("rd", "namespace", "collate")) -RoxygenNote: 7.2.1 +RoxygenNote: 7.3.2 +Config/testthat/edition: 3 SystemRequirements: C++11 diff --git a/NLMR.Rproj b/NLMR.Rproj index d3c89d7..4bc29f7 100644 --- a/NLMR.Rproj +++ b/NLMR.Rproj @@ -1,4 +1,5 @@ Version: 1.0 +ProjectId: c60b485c-12be-40a7-be11-f785e3cf8c20 RestoreWorkspace: Default SaveWorkspace: Default diff --git a/R/nlm_mpd.R b/R/nlm_mpd.R index d50c948..351d55f 100755 --- a/R/nlm_mpd.R +++ b/R/nlm_mpd.R @@ -7,14 +7,14 @@ #' algorithm. #' It performs the following steps: #' -#' \itemize{ -#' \item{Initialization: }{ Determine the smallest fit of -#' \code{max(ncol, nrow)} in \emph{n^2 + 1} and assign value to n. -#' Setup matrix of size (n^2 + 1)*(n^2 + 1). -#' Afterwards, assign a random value to the four corners of the matrix.} -#' \item{Square Step: }{ For each square in the matrix, assign the average of +#' \describe{ +#' \item{Initialization:}{Determine the smallest fit of +#' \code{max(ncol, nrow)} in \emph{n^2 + 1} and assign value to n. Setup matrix of +#' size (n^2 + 1)*(n^2 + 1). Afterwards, assign a random value to the four corners +#' of the matrix.} +#' \item{Square Step:}{For each square in the matrix, assign the average of #' the four corner points plus a random value to the midpoint of that square.} -#' \item{Diamond Step: }{ For each diamond in the matrix, assign the average +#' \item{Diamond Step:}{For each diamond in the matrix, assign the average #' of the four corner points plus a random value to the midpoint of that #' diamond.} #' } @@ -79,12 +79,12 @@ nlm_mpd <- function(ncol, # create the landscape with rcpp_mpd ---- seed <- sample.int(.Machine$integer.max, 1) mpd_raster <- rcpp_mpd(ncol, nrow, rand_dev, roughness, seed, torus) - + mpd_raster <- mpd_raster[-1,] mpd_raster <- mpd_raster[,-1] mpd_raster <- mpd_raster[-nrow(mpd_raster),] mpd_raster <- mpd_raster[,-ncol(mpd_raster)] - + # Convert matrix to raster ---- mpd_raster <- raster::raster(mpd_raster) diff --git a/R/nlm_percolation.R b/R/nlm_percolation.R index 25f27b5..5a8e9c1 100755 --- a/R/nlm_percolation.R +++ b/R/nlm_percolation.R @@ -14,9 +14,9 @@ #' @details #' The simulation of a random percolation map is accomplished in two steps: #' -#' \itemize{ -#' \item{Initialization: }{ Setup matrix of size (\code{ncol}*\code{nrow})} -#' \item{Map generation: }{ For each cell in the matrix a single uniformly +#' \describe{ +#' \item{Initialization:}{Setup matrix of size (\code{ncol}*\code{nrow})} +#' \item{Map generation:}{For each cell in the matrix a single uniformly #' distributed random number is generated and tested against a probability #' \code{prob}. If the random number is smaller than \code{prob}, the cell is set to #' TRUE - if it is higher the cell is set to FALSE.} diff --git a/README.Rmd b/README.Rmd index e38dcc8..eda9651 100644 --- a/README.Rmd +++ b/README.Rmd @@ -19,10 +19,8 @@ knitr::opts_chunk$set( [![R-CMD-check](https://github.com/ropensci/NLMR/workflows/R-CMD-check/badge.svg)](https://github.com/ropensci/NLMR/actions) [![codecov](https://codecov.io/gh/ropensci/NLMR/branch/develop/graph/badge.svg?token=MKCm2fVrDa)](https://codecov.io/gh/ropensci/NLMR) -[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/NLMR)](https://cran.r-project.org/package=NLMR) -[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing) -[![](http://cranlogs.r-pkg.org/badges/grand-total/NLMR)](http://cran.rstudio.com/web/packages/NLMR/index.html) -[![](https://badges.ropensci.org/188_status.svg)](https://github.com/ropensci/onboarding/issues/188) +[![Lifecycle](https://img.shields.io/badge/Lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html) +[![ropensci](https://badges.ropensci.org/188_status.svg)](https://github.com/ropensci/onboarding/issues/188) [![DOI:10.1111/2041-210X.13076](https://zenodo.org/badge/DOI/10.1111/2041-210X.13076.svg)](https://doi.org/10.1111/2041-210X.13076) diff --git a/_pkgdown.yml b/_pkgdown.yml index bdcef9c..4d2d91c 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,3 +1,5 @@ +url: https://ropensci.github.io/NLMR/ + reference: - title: Neutral Landscape Models desc: ~ diff --git a/man/nlm_mpd.Rd b/man/nlm_mpd.Rd index 7a7f2da..d0a4933 100644 --- a/man/nlm_mpd.Rd +++ b/man/nlm_mpd.Rd @@ -52,14 +52,14 @@ The algorithm is a direct implementation of the midpoint displacement algorithm. It performs the following steps: -\itemize{ - \item{Initialization: }{ Determine the smallest fit of - \code{max(ncol, nrow)} in \emph{n^2 + 1} and assign value to n. - Setup matrix of size (n^2 + 1)*(n^2 + 1). - Afterwards, assign a random value to the four corners of the matrix.} - \item{Square Step: }{ For each square in the matrix, assign the average of +\describe{ + \item{Initialization:}{Determine the smallest fit of + \code{max(ncol, nrow)} in \emph{n^2 + 1} and assign value to n. Setup matrix of + size (n^2 + 1)*(n^2 + 1). Afterwards, assign a random value to the four corners + of the matrix.} + \item{Square Step:}{For each square in the matrix, assign the average of the four corner points plus a random value to the midpoint of that square.} - \item{Diamond Step: }{ For each diamond in the matrix, assign the average + \item{Diamond Step:}{For each diamond in the matrix, assign the average of the four corner points plus a random value to the midpoint of that diamond.} } diff --git a/man/nlm_percolation.Rd b/man/nlm_percolation.Rd index ab80636..d86b084 100644 --- a/man/nlm_percolation.Rd +++ b/man/nlm_percolation.Rd @@ -28,9 +28,9 @@ Generates a random percolation neutral landscape model. \details{ The simulation of a random percolation map is accomplished in two steps: -\itemize{ - \item{Initialization: }{ Setup matrix of size (\code{ncol}*\code{nrow})} - \item{Map generation: }{ For each cell in the matrix a single uniformly +\describe{ + \item{Initialization:}{Setup matrix of size (\code{ncol}*\code{nrow})} + \item{Map generation:}{For each cell in the matrix a single uniformly distributed random number is generated and tested against a probability \code{prob}. If the random number is smaller than \code{prob}, the cell is set to TRUE - if it is higher the cell is set to FALSE.} diff --git a/tests/testthat.R b/tests/testthat.R index 3c66efe..510abfc 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,4 +1,12 @@ -library(testthat) -library(NLMR) - -test_check("NLMR") +# This file is part of the standard setup for testthat. +# It is recommended that you do not modify it. +# +# Where should you do additional test configuration? +# Learn more about the roles of various files in: +# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview +# * https://testthat.r-lib.org/articles/special-files.html + +library(testthat) +library(NLMR) + +test_check("NLMR") diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R new file mode 100644 index 0000000..8112e25 --- /dev/null +++ b/tests/testthat/setup.R @@ -0,0 +1,3 @@ +# load additional packages + +library(igraph)