diff --git a/.Rbuildignore b/.Rbuildignore index 6dddbab..315ca92 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,3 +3,4 @@ ^\.github prepareNewRelease.R LICENSE +codecov.yml \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..eacfb2d --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,10 @@ + + + +Checklist before merging: + +- [ ] Existing tests still work (check by running the test suite, e.g. from RStudio). +- [ ] Added tests (if you added functionality) or fixed existing test (if you fixed a bug). +- [ ] Updated or expanded the documentation. +- [ ] Updated release notes in `inst/NEWS.Rd` with a user-readable summary. Please, include references to relevant issues or PR discussions. +- [ ] Added your name to the contributors lists in the `DESCRIPTION` file, if you think you made a significant contribution. diff --git a/.github/workflows/r_codecov.yml b/.github/workflows/r_codecov.yml index 5a94268..cf9fa24 100644 --- a/.github/workflows/r_codecov.yml +++ b/.github/workflows/r_codecov.yml @@ -1,4 +1,4 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# 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: @@ -23,8 +23,28 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: covr + extra-packages: any::covr + needs: coverage - name: Test coverage - run: covr::codecov() - shell: Rscript {0} \ No newline at end of file + 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 \ No newline at end of file diff --git a/R/readGENEActiv.R b/R/readGENEActiv.R index ff397ce..6903dec 100644 --- a/R/readGENEActiv.R +++ b/R/readGENEActiv.R @@ -3,7 +3,7 @@ readGENEActiv = function(filename, start = 0, end = 0, progress_bar = FALSE, # Extract information from the fileheader suppressWarnings({fh = readLines(filename, 69)}) - # fh = fh[1:30] + SN = gsub(pattern = "Device Unique Serial Code:", replacement = "", x = fh[grep(pattern = "Device Unique Serial Code", x = fh)[1]]) firmware = gsub(pattern = "Device Firmware Version:", replacement = "", @@ -12,8 +12,11 @@ readGENEActiv = function(filename, start = 0, end = 0, progress_bar = FALSE, x = fh[grep(pattern = "Lux", x = fh)[1]])) Volts = as.numeric(gsub(pattern = "Volts:", replacement = "", x = fh[grep(pattern = "Volts", x = fh)[1]])) - starttime = gsub(pattern = "Start Time:", replacement = "", - x = fh[grep(pattern = "Start Time", x = fh)[1]]) + # We use first Page Time and not Start time from the file header + # because start time from the file header is known to be incorrect + # when battery runs out prior to end of recording + starttime = gsub(pattern = "Page Time:", replacement = "", + x = fh[grep(pattern = "Page Time", x = fh)[1]]) tzone = gsub(pattern = "Time Zone:", replacement = "", x = fh[grep(pattern = "Time Zone", x = fh)[1]]) @@ -30,8 +33,7 @@ readGENEActiv = function(filename, start = 0, end = 0, progress_bar = FALSE, DeviceModel = gsub(pattern = " ", replacement = "", x = gsub(pattern = "Device Model:", replacement = "", x = fh[grep(pattern = "Device Model", x = fh)[1]])) - - + # Read acceleration, lux and temperature data rawdata = GENEActivReader(filename = filename, start = start, end = end, @@ -69,7 +71,7 @@ readGENEActiv = function(filename, start = 0, end = 0, progress_bar = FALSE, # Correct timestamps page_offset = (((start - 1) * 300) / rawdata$info$SampleRate) - starttime_num = as.numeric(starttime_posix) + 5 + page_offset #tzone + + starttime_num = as.numeric(starttime_posix) + page_offset rawdata$time = rawdata$time + abs(rawdata$time[1]) + starttime_num return(invisible(list( header = header, diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..d6a6357 --- /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 \ No newline at end of file diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index 4eb44c7..d66b719 100755 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -1,6 +1,11 @@ \name{NEWS} \title{News for Package \pkg{GGIRread}} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} +\section{Changes in version 0.3.3 (GitHub-only-release date:23-01-2024)}{ + \itemize{ + \item When GENEActiv device battery runs low before downloading data the timestamp in the file header will default to 2010-9-16. This is now corrected by using the timestamp from the first page header instead, issue #56 + } +} \section{Changes in version 0.3.2 (GitHub-only-release date:05-12-2023)}{ \itemize{ \item Improved handling of failed checksum in .cwa files #53 (credits: Lena Kushleyeva)