Skip to content

Commit

Permalink
initializeFlagScheme,section-method added
Browse files Browse the repository at this point in the history
  • Loading branch information
dankelley committed May 12, 2018
1 parent 1675f55 commit 7990701
Show file tree
Hide file tree
Showing 18 changed files with 176 additions and 0 deletions.
21 changes: 21 additions & 0 deletions R/section.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,27 @@ setMethod("handleFlags",
res
})

#' @templateVar details This applies \code{initializeFlagScheme} for each \code{ctd} station within the \code{stations} element of the \code{data} slot.
#' @template initializeFlagSchemeTemplate
#'
#' @examples
#' data(section)
#' sectionWithFlags <- initializeFlagScheme(section, "WHP bottle")
#' station1 <- sectionWithFlags[["station", 1]]
#' str(station1[["flagScheme"]])
setMethod("initializeFlagScheme",
c(object="section", name="ANY", mapping="ANY", debug="ANY"),
function(object, name=NULL, mapping=NULL, debug=getOption("oceDebug")) {
res <- object
for (i in seq_along(object@data$station)) {
res@data$station[[i]] <- initializeFlagScheme(object@data$station[[i]], name, mapping, debug=debug-1)
}
res@processingLog <- processingLogAppend(res@processingLog,
paste("initializeFlagScheme(object",
", name=\"", name,
"\", mapping=", gsub(" ", "", paste(as.character(deparse(mapping))))))
res
})

#' @title Summarize a Section Object
#'
Expand Down
1 change: 1 addition & 0 deletions man/handleFlags-adp-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/handleFlags-argo-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/handleFlags-ctd-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/handleFlags-section-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/handleFlags.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/initializeFlagScheme-ctd-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/initializeFlagScheme-oce-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

121 changes: 121 additions & 0 deletions man/initializeFlagScheme-section-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/initializeFlagScheme.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/initializeFlags-adp-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/initializeFlags-oce-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/initializeFlags.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/setFlags-adp-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/setFlags-ctd-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/setFlags-oce-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/setFlags.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions tests/testthat/test_flags.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ test_that("user-created flag scheme", {
mapping=list(unknown=1, good=2, bad=3)))
})

test_that("cannot alter existing flag scheme", {
data(ctd)
a <- initializeFlagScheme(ctd, "myscheme", list(unknown=1, good=2, bad=3))
expect_warning(initializeFlagScheme(a, "WHP CTD"),
"cannot alter a flagScheme that is already is place")
})

test_that("ctd flag scheme action", {
data(ctd)
a <- initializeFlags(ctd, "temperature", 2) # 2="acceptable
Expand Down Expand Up @@ -205,3 +212,15 @@ test_that("does subset() work on adp flags? (issue 1410)", {
expect_equal(adp[["vFlag"]][look, , ], sub[["vFlag"]]) # flag values ok?
})



test_that("set flags on section object", {
data(section)
a <- initializeFlagScheme(section, "WHP bottle")
expect_equal(a[["station", 1]][["flagScheme"]],
list(name="WHP bottle",
mapping=list(no_information=1, no_problems_noted=2, leaking=3,
did_not_trip=4, not_reported=5, discrepency=6,
unknown_problem=7, did_not_trip=8, no_sample=9)))
})

0 comments on commit 7990701

Please sign in to comment.