Skip to content

Commit

Permalink
code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
rosieluain committed Jan 23, 2024
1 parent 8c79ff2 commit e43ac2d
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 1 deletion.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
^cran-comments\.md$
^doc$
^Meta$
^codecov\.yml$
55 changes: 55 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 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:
branches: [main, master]

name: test-coverage

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3

- 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
needs: coverage

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

- 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@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Imports:
methods,
rlang
Suggests:
covr,
ggplot2,
knitr,
plotly,
Expand Down
28 changes: 27 additions & 1 deletion R/mort.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto",
}
}

# Check that all records have a station assigned
if (nrow(data[is.na(data[[station]]),])>0){
stop("Station must be specified for all records.")
}

data.full<-data
if (!is.null(season.start)|
!is.null(season.end)){
Expand Down Expand Up @@ -680,6 +685,11 @@ infrequent<-function(data,type="mort",ID,station,res.start="auto",
}
}

# Check that all records have a station assigned
if (nrow(data[is.na(data[[station]]),])>0){
stop("Station must be specified for all records.")
}

if (any(data[[station]]=="Break")){
warning("Either a station name was 'Break' or data included seasonal
breaks. Breaks were removed.")
Expand Down Expand Up @@ -764,7 +774,23 @@ infrequent<-function(data,type="mort",ID,station,res.start="auto",
res.temp[[res.end]],
units=recent.units)<=recent.period))
res.temp<-res.temp[j:nrow(res.temp),]
if (is.null(ddd)){
if (nrow(res.temp)>0&length(unique(res.temp$Station.Name))==1){
if (sum(res.temp[[residences]])<threshold){
if (tag[i] %in% inf.morts[[ID]]){
k<-which(inf.morts[[ID]]==tag[i])
if (res.temp[[res.start]][1]<inf.morts[[res.start]][k]){
inf.morts[k,]<-res.temp[1,]
if (!is.null(morts.prev)&backwards==TRUE){
new.morts<-c(new.morts,k)
}
}
}
else {
inf.morts[nrow(inf.morts)+1,]<-res.temp[1,]
}
}
}
else if (is.null(ddd)){
if (nrow(res.temp)>=1&
length(unique(res.temp[[station]]))==1&
sum(res.temp[[residences]])<threshold){
Expand Down
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ knitr::opts_chunk$set(
# mort <img src="man/figures/logo.png" align="right" height="139" />

<!-- badges: start -->
[![Codecov test coverage](https://codecov.io/gh/rosieluain/mort/branch/main/graph/badge.svg)](https://app.codecov.io/gh/rosieluain/mort?branch=main)
<!-- badges: end -->

The goal of mort is to provide a framework to identify potential mortalities or expelled tags in passive acoustic telemetry arrays with non-overlapping receivers. The potential mortalities that are flagged by mort should be reviewed by the user, and considered for removal from the dataset.
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# mort <img src="man/figures/logo.png" align="right" height="139" />

<!-- badges: start -->

[![Codecov test
coverage](https://codecov.io/gh/rosieluain/mort/branch/main/graph/badge.svg)](https://app.codecov.io/gh/rosieluain/mort?branch=main)
<!-- badges: end -->

The goal of mort is to provide a framework to identify potential
Expand Down
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
comment: false

coverage:
status:
project:
default:
target: auto
threshold: 1%
informational: true
patch:
default:
target: auto
threshold: 1%
informational: true

0 comments on commit e43ac2d

Please sign in to comment.