Skip to content

Commit

Permalink
Merge branch 'why-it-works-vignette' of https://github.com/SamuelBran…
Browse files Browse the repository at this point in the history
…d1/primarycensoreddist into why-it-works-vignette
  • Loading branch information
SamuelBrand1 committed Sep 18, 2024
2 parents 62ec9ed + 6120812 commit 05daf84
Show file tree
Hide file tree
Showing 11 changed files with 415 additions and 4 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
^vignettes/using-stan-tools\.Rmd$
^vignettes/fitting-dists-with-stan\.Rmd$
^inst/pcens_model$
^touchstone$
20 changes: 20 additions & 0 deletions .github/workflows/benchmarks-comment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Benchmarks (Comment)

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

on:
workflow_run:
workflows:
- Benchmarks
types:
- completed

jobs:
upload:
runs-on: ubuntu-latest
steps:
- uses: seabbs/touchstone/actions/comment@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81 changes: 81 additions & 0 deletions .github/workflows/benchmarks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Benchmarks

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

on:
pull_request:
paths:
# Directories with source code and benchmarking code
- "inst/stan/**"
- "R/**"
- "src/**"
- "touchstone/**"
# Stan model
- "inst/pcens_model.stan"
# Benchmarking config file
- ".github/workflows/benchmarks*.yaml"
# Benchmarking action
- ".github/actions/touchstone-recieve/**"
# Package metadata
- DESCRIPTION
workflow_dispatch:

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
config: ${{ steps.read_touchstone_config.outputs.config }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- id: read_touchstone_config
run: |
content=`cat ./touchstone/config.json`
# the following lines are only required for multi line json
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
# end of optional handling for multi line json
echo "::set-output name=config::$content"
build:
needs: prepare
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- ${{ fromJson(needs.prepare.outputs.config) }}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
extra-repositories: 'https://stan-dev.r-universe.dev'

- name: Install cmdstanr
run: install.packages("cmdstanr")
shell: Rscript {0}

- name: Install cmdstan
uses: epinowcast/actions/install-cmdstan@v1
with:
cmdstan-version: 'latest'
num-cores: 2

- uses: seabbs/touchstone/actions/receive@main
with:
cache-version: 1
touchstone_ref: '@f5c859e'
benchmarking_repo: ${{ matrix.config.benchmarking_repo }}
benchmarking_ref: ${{ matrix.config.benchmarking_ref }}
benchmarking_path: ${{ matrix.config.benchmarking_path }}
extra-repositories: 'https://stan-dev.r-universe.dev'
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: primarycensoreddist
Title: Primary Event Censored Distributions in R and Stan
Version: 0.3.0.1000
Version: 0.4.0.1000
Authors@R:
c(person(given = "Sam",
family = "Abbott",
Expand Down
12 changes: 11 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# primarycensoreddist 0.3.0.1000
# primarycensoreddist 0.4.0.1000

This is the current development version.

## Package

* Add `{touchstone}` based benchmarks for benchmarking R utility functions, and fitting the `stan` and `fitdistplus` models.

# primarycensoreddist 0.4.0

In this release, we have added a new package `stan` model for fitting distributions using the `cmdstanr` package. We have also added a new function `fitdistdoublecens()` to allow for fitting of double censored and truncated data using the `fitdistrplus` package. As well as these functionality improvements this release focuses on improving the stability of the `stan` model and improving the speed of the `primary_censored_ode` function.

## Package

Expand Down
4 changes: 2 additions & 2 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "https://github.com/epinowcast/primarycensoreddist/",
"issueTracker": "https://github.com/epinowcast/primarycensoreddist/issues/",
"license": "https://spdx.org/licenses/MIT",
"version": "0.3.0.1000",
"version": "0.4.0.1000",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -167,7 +167,7 @@
},
"SystemRequirements": null
},
"fileSize": "296.764KB",
"fileSize": "343.237KB",
"citation": [
{
"@type": "SoftwareSourceCode",
Expand Down
6 changes: 6 additions & 0 deletions touchstone/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!script.R
!config.json
!.gitignore
!header.R
!footer.R
5 changes: 5 additions & 0 deletions touchstone/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"os": "ubuntu-latest",
"r": "release",
"rspm": "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"
}
10 changes: 10 additions & 0 deletions touchstone/footer.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# You can modify the PR comment footer here. You can use github markdown e.g.
# emojis like :tada:.
# This file will be parsed and evaluate within the context of
# `benchmark_analyze` and should return the comment text as the last value.
# See `?touchstone::pr_comment`
link <- "https://lorenzwalthert.github.io/touchstone/articles/inference.html"
glue::glue(
"\nFurther explanation regarding interpretation",
" and methodology can be found in the [documentation of `touchstone`]({link})." # nolint
)
13 changes: 13 additions & 0 deletions touchstone/header.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# You can modify the PR comment header here. You can use github markdown e.g.
# emojis like :tada:.
# This file will be parsed and evaluate within the context of
# `benchmark_analyze` and should return the comment text as the last value.
# Available variables for glue substitution:
# * ci: confidence interval
# * branches: BASE and HEAD branches benchmarked against each other.
# See `?touchstone::pr_comment`
glue::glue(
"This is how benchmark results would change (along with a",
" {100 * ci}% confidence interval in relative change) if ",
"{system2('git', c('rev-parse', 'HEAD'), stdout = TRUE)} is merged into {branches[1]}:\n" # nolint
)
Loading

0 comments on commit 05daf84

Please sign in to comment.