Skip to content

Commit

Permalink
Try to fix coverage together
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-imbi committed Jul 10, 2024
1 parent 48c436d commit 6d0decd
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 25 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,54 @@ on:

name: test-coverage

permissions: read-all

jobs:
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
6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ knitr::opts_chunk$set(
[![License](https://img.shields.io/badge/License-GPL_v2-blue.svg)](https://github.com/jan-imbi/adestr/blob/master/LICENSE.md)
<!-- badges: end -->


This package implements methods to evaluate the performance characteristics
of various point and interval estimators for adaptive two-stage designs with
prespecified sample-size recalculation rules. Further, it allows for
evaluation of these estimators on real datasets, and it implements methods
to calculate p-values.

Currently, it works for designs objects which were produced by the
R-package `adoptr`, which calculates optimal design parameters adaptive
R-package [`adoptr`](https://github.com/optad/adoptr), which calculates optimal design parameters adaptive
two-stage designs.

An introductory vignette covering common usecases is given at [https://jan-imbi.github.io/adestr/articles/Introduction.html](https://jan-imbi.github.io/adestr/articles/Introduction.html).

The test [https://jan-imbi.github.io/adestr/articles/Introduction.html](https://jan-imbi.github.io/adestr/articles/Introduction.html).
This package comes suite of unit tests. The code of the test cases can be viewed here: [https://github.com/jan-imbi/adestr/tree/master/tests/testthat](https://github.com/jan-imbi/adestr/tree/master/tests/testthat). The authors assume no responsibility for the correctness of the
code or results produced by its usage. Use at your own risk.

<!-- reference implementation verlinken -->

Expand Down
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,19 @@ Further, it allows for evaluation of these estimators on real datasets,
and it implements methods to calculate p-values.

Currently, it works for designs objects which were produced by the
R-package `adoptr`, which calculates optimal design parameters adaptive
two-stage designs.
R-package [`adoptr`](https://github.com/optad/adoptr), which calculates
optimal design parameters adaptive two-stage designs.

An introductory vignette covering common usecases is given at
<https://jan-imbi.github.io/adestr/articles/Introduction.html>.

This package comes suite of unit tests. The code of the test cases can
be viewed here:
<https://github.com/jan-imbi/adestr/tree/master/tests/testthat>. The
authors assume no responsibility for the correctness of the code or
results produced by its usage. Use at your own risk.

<!-- reference implementation verlinken -->

## Installation

Expand All @@ -32,22 +43,14 @@ remotes::install_github("https://github.com/jan-imbi/adestr")

into your R console.

## Information for reviewers

The scripts to reproduce the results from the paper can be found in the
`/data/code/` directory of this repository. The results themselves are
located in the `/data/` directory.

The easiest way to inspect the results is to [clone this
repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository).

## General example for usage of the package
## Small introductory example

Here is a quick example showing the capabilities of `adestr`. First,
load `adestr`:

``` r
library(adestr)
#> Loading required package: adoptr
```

Then, you can evaluate the performance of an estimator like this:
Expand Down Expand Up @@ -129,3 +132,7 @@ analyze(
#> SWCF ordering p-value: 0.01097483
#> LR test ordering p-value: 6.653031e-05
```

Please refer to
<https://jan-imbi.github.io/adestr/articles/Introduction.html> for a
more detailed introduction.
17 changes: 17 additions & 0 deletions tests/testthat/test_helpers.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
test_that("Transformation convenience functions work",
{
expect_equal(t_to_z(z_to_t(1.234, 1.3, 2.1, 23), 1.3, 2.1, 23), 1.234)
expect_equal(smean_to_t(1.2, 3.4, 45, FALSE), 1.2/sqrt(3.4) * sqrt(45))
expect_equal(smeans_to_smean(1, 2, 30, 30), 1.5)
expect_equal(svar_to_se(2.3, 40, FALSE), sqrt(2.3/40))
expect_equal(t_test(1.2, 3.4, 50, FALSE), 1.2/sqrt(3.4)*sqrt(50))
expect_equal(pool_svar1_svar2(1.2, 3.4, 50, 60, FALSE), (49 * 1.2 + 59 * 3.4) / (108))
})



test_that("Generation of example statistics doesn't produce an error",
{
expect_error(get_example_statistics(), NA)
expect_error(get_statistics_from_paper (), NA)
})
13 changes: 9 additions & 4 deletions vignettes/Introduction.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,22 @@ to calculate p-values.
Currently, it works for designs objects which were produced by the
R-package `adoptr`, which calculates optimal design parameters for
adaptive two-stage designs. You can learn about adoptr here:
[kkmann.github.io/adoptr/](https://kkmann.github.io/adoptr/).
[optad.github.io/adoptr/](https://optad.github.io/adoptr/).

An introductory vignette covering common usecases is given at [https://jan-imbi.github.io/adestr/articles/Introduction.html](https://jan-imbi.github.io/adestr/articles/Introduction.html).

This package comes suite of unit tests. The code of the test cases can be viewed here: [https://github.com/jan-imbi/adestr/tree/master/tests/testthat](https://github.com/jan-imbi/adestr/tree/master/tests/testthat). The authors assume no responsibility for the correctness of the
code or results produced by its usage. Use at your own risk.

# Fitting a design with adoptr
In order to showcase the capabilities of this package, we need a trial design first.
We refer to [the example from the adoptr documentation](https://kkmann.github.io/adoptr/articles/adoptr.html)
We refer to [the example from the adoptr documentation](https://optad.github.io/adoptr/articles/adoptr.html)
for this.
You can read more about optimal adaptive designs fitted via the adoptr package here:
[kkmann.github.io/adoptr/articles/adoptr_jss.html](https://kkmann.github.io/adoptr/articles/adoptr_jss.html).
[optad.github.io/adoptr/articles/adoptr_jss.html](https://optad.github.io/adoptr/articles/adoptr_jss.htmll).

For the sake of this introduction, a pre-computed version of the first example from
[kkmann.github.io/adoptr/articles/adoptr.html](https://kkmann.github.io/adoptr/articles/adoptr.html)
[optad.github.io/adoptr/articles/adoptr.html](https://optad.github.io/adoptr/articles/adoptr.html)
is provided with this package via the `get_example_design` function.

```{r}
Expand Down

0 comments on commit 6d0decd

Please sign in to comment.