Skip to content

Commit

Permalink
Merge branch 'main' into upkeep
Browse files Browse the repository at this point in the history
  • Loading branch information
nehill197 authored Sep 17, 2024
2 parents 65a92ac + f91bd81 commit 59c0240
Show file tree
Hide file tree
Showing 31 changed files with 164 additions and 54 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 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
#
# NOTE: This workflow is overkill for most R packages and
# check-standard.yaml is likely a better choice.
# usethis::use_github_action("check-standard") will install it.
on:
push:
branches: [main, master]
Expand All @@ -21,7 +25,9 @@ jobs:
matrix:
config:
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'release'}

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/check-no-suggests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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
#
# NOTE: This workflow only directly installs "hard" dependencies, i.e. Depends,
# Imports, and LinkingTo dependencies. Notably, Suggests dependencies are never
# installed, with the exception of testthat, knitr, and rmarkdown. The cache is
# never used to avoid accidentally restoring a cache containing a suggested
# dependency.
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: check-no-suggests.yaml

permissions: read-all

jobs:
check-no-suggests:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-latest, r: 'release'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- 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-r-dependencies@v2
with:
dependencies: '"hard"'
cache: false
extra-packages: |
any::rcmdcheck
any::testthat
any::knitr
any::rmarkdown
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
21 changes: 7 additions & 14 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@ on:
types: [published]
workflow_dispatch:

name: pkgdown
name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -40,18 +43,8 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.4.1
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
folder: docs

- name: action-slack
if: failure()
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
uses: 8398a7/[email protected]
with:
status: ${{ job.status }}
author_name: "github action: ${{github.workflow}}"
fields: repo, ref, commit, author, message
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,56 @@ on:
pull_request:
branches: [main, master]

name: coverage
name: test-coverage.yaml

permissions: read-all

jobs:
coverage:
if: "!contains(github.event.head_commit.message, 'skip ci')"
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
covr::codecov(
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: extras
Title: Helper Functions for Bayesian Analyses
Version: 0.7.2.9000
Version: 0.7.3.9000
Authors@R: c(
person("Nicole", "Hill", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-7623-2153")),
Expand Down Expand Up @@ -49,3 +49,5 @@ Encoding: UTF-8
Language: en-US
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
VignetteBuilder: knitr
Config/Needs/website: poissonconsulting/poissontemplate
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export(odds)
export(odds_ratio)
export(odds_ratio2)
export(par_pattern)
export(params)
export(pbern)
export(pextreme)
export(phi)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

<!-- NEWS.md is maintained by https://fledge.cynkra.com, contributors should not edit this file -->

# extras 0.7.3

- Ensure all tests, examples, and vignettes run conditionally for packages listed in suggests.

# extras 0.7.2

- Fix behaviour of `dev_beta_binom()` when size \< x.
Expand Down
3 changes: 2 additions & 1 deletion R/dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,12 @@ dev_pois_zi <- function(x, lambda, prob = 0, res = FALSE) {
#' @family dev_dist
#' @export
#'
#' @examples
#' @examplesIf requireNamespace("sn")
#' dev_skewnorm(c(-2:2))
#' dev_skewnorm(-2:2, 0, 1, 5)
#' dev_skewnorm(-2:2, 0, 1, 5, res = TRUE)
dev_skewnorm <- function(x, mean = 0, sd = 1, shape = 0, res = FALSE) {
rlang::check_installed("sn")
delta <- shape / sqrt(1 + shape^2)
mu_z <- sqrt(2 / pi) * delta
sig_z <- sqrt(1 - mu_z^2)
Expand Down
2 changes: 2 additions & 0 deletions R/extras-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@

## usethis namespace: start
#' @importFrom lifecycle deprecated
#' @import chk
#' @importFrom stats dbinom dlnorm dnorm dpois dnbinom
## usethis namespace: end
NULL
1 change: 1 addition & 0 deletions R/fabs.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#'
#' @param x An existing R object.
#' @family translations
#' @return A numeric vector of the corresponding absolute values.
#' @export
#' @examples
#' fabs(c(0, -1, 2))
Expand Down
3 changes: 2 additions & 1 deletion R/log-lik.R
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,12 @@ log_lik_pois_zi <- function(x, lambda = 1, prob = 0) {
#' @family log_lik_dist
#' @export
#'
#' @examples
#' @examplesIf requireNamespace("sn")
#' log_lik_skewnorm(c(-2:2))
#' log_lik_skewnorm(c(-2:2), shape = -2)
#' log_lik_skewnorm(c(-2:2), shape = 2)
log_lik_skewnorm <- function(x, mean = 0, sd = 1, shape = 0) {
rlang::check_installed("sn")
log_lik <- dskewnorm(x = x, mean = mean, sd = sd, shape = shape, log = TRUE)
use_norm <- !is.na(shape) & shape == 0
lnorm <- log_lik_norm(x = x, mean = mean, sd = sd)
Expand Down
3 changes: 0 additions & 3 deletions R/namespace.R

This file was deleted.

1 change: 1 addition & 0 deletions R/numericise.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ numericise.POSIXct <- function(x, ...) {
#' @examples
#'
#' # hms
#' @examplesIf requireNamespace("hms")
#' numericise(hms::as_hms("00:01:03"))
numericise.hms <- function(x, ...) {
rlang::check_installed("hms")
Expand Down
1 change: 1 addition & 0 deletions R/params.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#' @param x An object.
#' @aliases parameters arguments args
#' @usage NULL
#' @export
# nocov start
params <- function(...) NULL
# nocov end
3 changes: 2 additions & 1 deletion R/ran.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,12 @@ ran_pois_zi <- function(n = 1, lambda = 1, prob = 0) {
#' @family ran_dist
#' @export
#'
#' @examples
#' @examplesIf requireNamespace("sn")
#' ran_skewnorm(10, shape = -1)
#' ran_skewnorm(10, shape = 0)
#' ran_skewnorm(10, shape = 1)
ran_skewnorm <- function(n = 1, mean = 0, sd = 1, shape = 0) {
rlang::check_installed("sn")
chk_whole_number(n)
chk_gte(n)
rskewnorm(n = n, mean = mean, sd = sd, shape = shape)
Expand Down
3 changes: 2 additions & 1 deletion R/res.R
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,10 @@ res_student_standardized <- function(x, mean, sd, theta) {
#' @family res_dist
#' @export
#'
#' @examples
#' @examplesIf requireNamespace("sn")
#' res_skewnorm(c(-2:2))
res_skewnorm <- function(x, mean = 0, sd = 1, shape = 0, type = "dev", simulate = FALSE) {
rlang::check_installed("sn")
chk_string(type)
if (!vld_false(simulate)) {
x <- ran_skewnorm(length(x), mean = mean, sd = sd, shape = shape)
Expand Down
2 changes: 1 addition & 1 deletion R/sens.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ sens_student <- function(mean, sd, theta, sd_mult = 2) {
#' @family sens_dist
#' @export
#'
#' @examples
#' @examplesIf requireNamespace("sn")
#' sens_skewnorm(10, 3, -1, 2)
#' sens_skewnorm(10, 3, 3, 0.8)
sens_skewnorm <- function(mean, sd, shape, sd_mult = 2) {
Expand Down
2 changes: 1 addition & 1 deletion R/skewnorm.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' @rdname skewnorm
#' @export
#'
#' @examples
#' @examplesIf requireNamespace("sn")
#' dskewnorm(x = -2:2, mean = 0, sd = 1, shape = 0.1)
#' dskewnorm(x = -2:2, mean = 0, sd = 1, shape = -1)
#' qskewnorm(p = c(0.1, 0.4), mean = 0, sd = 1, shape = 0.1)
Expand Down
15 changes: 2 additions & 13 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
## R CMD check results

0 errors | 0 warnings | 1 note

New maintainer:
Nicole Hill <[email protected]>
Old maintainer(s):
Joe Thorley <[email protected]>
0 errors | 0 warnings | 0 notes

## CRAN Issues

Fixed the following error by conditionally skipping tests that rely on packages listed in suggests, if those packages are not installed.
After review, also decided to remove the dependency to the 'aods3' package.

══ Failed tests ════════════════════════════════════════════════════════════════
── Error ('test-log-lik.R:184:3'): beta_binom log_lik ──────────────────────────
<packageNotFoundError/error/condition>
Error in `loadNamespace(x)`: there is no package called 'aods3'
After feedback, corrected the noSuggests issue to have all tests, examples, and vignettes run conditionally for packages listed under Suggests.

## revdepcheck results

Expand Down
2 changes: 1 addition & 1 deletion inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Summarise
Surprisal
TMB
WinBUGS
behaviour
bern
bigg
cdot
Expand All @@ -24,7 +25,6 @@ lik
modelling
numericise
skewnorm
styler
summarise
surprisal
testthat
Expand Down
2 changes: 2 additions & 0 deletions man/dev_skewnorm.Rd

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

3 changes: 3 additions & 0 deletions man/fabs.Rd

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

Loading

0 comments on commit 59c0240

Please sign in to comment.