Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added progress bar fix for axivity #64

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions R/readAxivity.R
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,6 @@ readAxivity = function(filename, start = 0, end = 0, progressBar = FALSE, desire
return(invisible(list(header = header, data = NULL)))
}

# Create progress bar if it is necessary
if (progressBar) {
pb = txtProgressBar(1, nr, style = 3)
}

# Read the end block, to determine the end timestamp.
struc = list(0,0L,0)
if (end < numDBlocks) { # the end block isn't part of the data we'll read, but its start will be our ending timestamp
Expand Down Expand Up @@ -505,6 +500,11 @@ readAxivity = function(filename, start = 0, end = 0, progressBar = FALSE, desire
battery = vector(mode = "double", nr)
light = vector(mode = "double", nr)

# Create progress bar if it is necessary
if (progressBar) {
pb = txtProgressBar(1, nr, style = 3)
}

# Allocate enough space for the expected number of samples in a block, plus an extra ones needed for resampling.
# Don't rely on the type of device to determine the dimensionality of the data
# because AX6 can be configured to only collect accelerometer data.
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test_readAxivity.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ test_that("readAxivity reads data from AX3 file correctly", {

})

test_that("readAxivity does not fail on progressBar=TRUE for AX3 file", {
cwafile = system.file("testfiles/ax3_testfile.cwa", package = "GGIRread")[1]
AX3 = readAxivity(filename = cwafile, desiredtz = "Europe/Berlin", start = 1,
end = 4, progressBar = TRUE)
expect_equal(AX3$header$device, "Axivity")
})


test_that("readAxivity handles failed checksums correctly", {
# read the blocks 1-11 from the non-corrupt file
cwafile = system.file("testfiles/ax3_testfile.cwa", package = "GGIRread")[1]
Expand Down
Loading