diff --git a/.Rbuildignore b/.Rbuildignore index aa8d6e8..e00a0e4 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -12,3 +12,4 @@ ^README\.Rmd$ ^CRAN-SUBMISSION$ ^revdep$ +^codecov\.yml$ diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..562fe0f --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,51 @@ +# 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] + pull_request: + +name: R-CMD-check.yaml + +permissions: read-all + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + 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'} + + 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: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..0ab748d --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,62 @@ +# 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] + pull_request: + +name: test-coverage.yaml + +permissions: read-all + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - 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, any::xml2 + needs: coverage + + - name: Test coverage + run: | + cov <- covr::package_coverage( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + print(cov) + covr::to_cobertura(cov) + shell: Rscript {0} + + - uses: codecov/codecov-action@v5 + with: + # Fail if error if not on PR, or if on PR and token is given + fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }} + files: ./cobertura.xml + plugins: 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 + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v4 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/NEWS.md b/NEWS.md index 98b9c83..2f661fd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,12 @@ # massProps (development version) -* Covariance exposition for RoG uncertainty clarified (#43) +* Invocation instructions in vignette cleaned up (#41). + +* Covariance exposition for RoG uncertainty clarified (#43). + +* Initialization in rollup_radii_of_gyration_unc() cleaned up (#44). + +* igraph loading fix for vignette (#48). # massProps 0.3.1 diff --git a/R/radii.R b/R/radii.R index bb6fb89..5145a8a 100644 --- a/R/radii.R +++ b/R/radii.R @@ -71,7 +71,7 @@ rollup_radii_of_gyration_unc <- function(tree, df) { }, sources ), - init <- c(0, 0, 0) + init = c(0, 0, 0) ) ) / 2 set_radii_of_gyration_unc(ds, target, amp) diff --git a/README.Rmd b/README.Rmd index 8ea9d6c..60f66f6 100644 --- a/README.Rmd +++ b/README.Rmd @@ -17,6 +17,9 @@ knitr::opts_chunk$set( # massProps +[![CRAN status](https://www.r-pkg.org/badges/version/massProps)](https://CRAN.R-project.org/package=massProps) +[![R-CMD-check](https://github.com/jsjuni/massProps/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jsjuni/massProps/actions/workflows/R-CMD-check.yaml) +[![Codecov test coverage](https://codecov.io/gh/jsjuni/massProps/graph/badge.svg)](https://app.codecov.io/gh/jsjuni/massProps) The `massProps` package extends `rollupTree` with functions to recursively calculate mass properties (and optionally, their uncertainties) for arbitrary composition trees. Formulas implemented are described in a technical paper published by the Society of Allied Weight Engineers [@zimmerman:05:sawe]. diff --git a/README.md b/README.md index 39b8106..283f7a1 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,11 @@ +[![CRAN +status](https://www.r-pkg.org/badges/version/massProps)](https://CRAN.R-project.org/package=massProps) +[![R-CMD-check](https://github.com/jsjuni/massProps/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jsjuni/massProps/actions/workflows/R-CMD-check.yaml) +[![Codecov test +coverage](https://codecov.io/gh/jsjuni/massProps/graph/badge.svg)](https://app.codecov.io/gh/jsjuni/massProps) The `massProps` package extends `rollupTree` with functions to diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..04c5585 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,14 @@ +comment: false + +coverage: + status: + project: + default: + target: auto + threshold: 1% + informational: true + patch: + default: + target: auto + threshold: 1% + informational: true diff --git a/vignettes/massProps.Rmd b/vignettes/massProps.Rmd index e7fbf67..d9e7b54 100644 --- a/vignettes/massProps.Rmd +++ b/vignettes/massProps.Rmd @@ -141,9 +141,7 @@ The tree is an `igraph::graph` with vertices named by identifiers in the mass pr ## Invocation ```{r setup} -library(rollupTree) library(massProps) -suppressPackageStartupMessages({library(igraph)}) ``` Suppose we have the following mass properties table: @@ -154,12 +152,16 @@ test_table Suppose we also have this tree: +```{r echo = FALSE} +suppressPackageStartupMessages({library(igraph)}) +``` ```{r} +library(igraph) test_tree ``` ```{r echo = FALSE} -plot(test_tree,layout=layout_as_tree(test_tree, 2, mode="in"), vertex.shape = 'none', edge.arrow.mode = 0) +igraph::plot.igraph(test_tree,layout=igraph::layout_as_tree(test_tree, 2, mode="in"), vertex.shape = 'none', edge.arrow.mode = 0) ``` Then we can compute mass properties for non-leaf elements by calling `rollup_mass_props()`: @@ -189,7 +191,7 @@ na_mass_props_and_unc <- function(d, t, v) { na_mass_props_and_unc_update <- function(d, t, s) { update_mass_props_and_unc(d, t, s, override = na_mass_props_and_unc) } -sawe_input <- rollup(sawe_tree, sawe_table, update = na_mass_props_and_unc_update, validate_ds = validate_mass_props_and_unc_table) +sawe_input <- rollupTree::rollup(sawe_tree, sawe_table, update = na_mass_props_and_unc_update, validate_ds = validate_mass_props_and_unc_table) ``` ```{r} @@ -806,7 +808,7 @@ The corresponding R code is }, sources ), - init <- c(0, 0, 0) + init = c(0, 0, 0) ) ) / 2 ``` @@ -1100,7 +1102,7 @@ The SAWE reference provides computed results for their example (excluding radii # Performance Evaluation ```{r echo = FALSE} -mp_tree_depth <- max(dfs(mp_tree, 2, mode = "in", order=FALSE, dist=TRUE)$dist) + 1 +mp_tree_depth <- max(igraph::dfs(mp_tree, 2, mode = "in", order=FALSE, dist=TRUE)$dist) + 1 nv <- length(igraph::V(mp_tree)) ne <- length(igraph::E(mp_tree)) nl <- length(which(igraph::degree(mp_tree, mode="in") == 0))