Skip to content

Commit

Permalink
simplifyArtifact/FragmentData: expect silent output when some horizon…
Browse files Browse the repository at this point in the history
…s have no records
  • Loading branch information
brownag committed Sep 25, 2024
1 parent 1755770 commit 7bea3f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
7 changes: 3 additions & 4 deletions tests/testthat/test-simplifyArtifactData.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ test_that("simplifyArtifactData when missing fragment sizes, low/rv/high", {

# all fragments are coallated into the unspecified column
# totals should be correct
# some horizons have no fragment records, should generate a warning
# some horizons have no fragment records
d.missing.size <- d.artifact.hz
d.missing.size[,c("huartsize_l", "huartsize_r", "huartsize_h")] <- NA
d.missing.size[4,] <- d.missing.size[3,]
d.missing.size[4,] <- NA
d.missing.size[4,'phiid'] <- "10102"
expect_message(res <- simplifyArtifactData(d.missing.size, id.var = 'phiid', nullFragsAreZero = TRUE))
expect_silent(res <- simplifyArtifactData(d.missing.size, id.var = 'phiid', nullFragsAreZero = TRUE))

# rows missing fragvol should be removed from the simplified result
expect_true(nrow(d.missing.size) == 4)
Expand All @@ -171,8 +171,7 @@ test_that("simplifyArtifactData warning generated when NA in huartvol", {
d.missing.artvol <- d.artifact.hz
d.missing.artvol$huartvol <- NA
d.missing.artvol[1,'huartvol'] <- 10
expect_message(simplifyArtifactData(d.missing.artvol, id.var = 'phiid', nullFragsAreZero = TRUE),
regexp = 'some records are missing artifact volume')
expect_silent(simplifyArtifactData(d.missing.artvol, id.var = 'phiid', nullFragsAreZero = TRUE))
})


Expand Down
13 changes: 6 additions & 7 deletions tests/testthat/test-simplifyFragmentData.R
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,10 @@ test_that("simplifyFragmentData complex sample data from NASIS, single horizon",

test_that("simplifyFragmentData when missing fragment sizes, low/rv/high", {

# all fragments are coallated into the unspecified column
# all fragments are collated into the unspecified column
# totals should be correct
# some horizons have no fragment records, should generate a warning
expect_message( { res <- simplifyFragmentData(d.missing.size, id.var = 'phiid', nullFragsAreZero = TRUE) } )
# some horizons have no fragment records
expect_silent( { res <- simplifyFragmentData(d.missing.size, id.var = 'phiid', nullFragsAreZero = TRUE) } )

# rows missing fragvol should be removed from the simplified result
expect_true(nrow(d.missing.size) == 12)
Expand All @@ -467,8 +467,7 @@ test_that("simplifyFragmentData when missing fragment sizes, low/rv/high", {

test_that("simplifyFragmentData warning generated when NA in fragvol", {

expect_message(simplifyFragmentData(d.missing.fragvol, id.var = 'phiid', nullFragsAreZero = TRUE),
regexp = 'some records are missing rock fragment volume')
expect_silent(simplifyFragmentData(d.missing.fragvol, id.var = 'phiid', nullFragsAreZero = TRUE))

})

Expand All @@ -482,8 +481,8 @@ test_that("simplifyFragmentData warning generated when all fragvol are NA", {


test_that("simplifyFragmentData nullFragsAreZero works as expected", {
expect_message( { a <- simplifyFragmentData(d.missing.fragvol, id.var = 'phiid', nullFragsAreZero = FALSE) } )
expect_message( { b <- simplifyFragmentData(d.missing.fragvol, id.var = 'phiid', nullFragsAreZero = TRUE) } )
expect_silent( { a <- simplifyFragmentData(d.missing.fragvol, id.var = 'phiid', nullFragsAreZero = FALSE) } )
expect_silent( { b <- simplifyFragmentData(d.missing.fragvol, id.var = 'phiid', nullFragsAreZero = TRUE) } )
expect_equal(as.logical(is.na(a)),
c(FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE,
FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE))
Expand Down

0 comments on commit 7bea3f9

Please sign in to comment.