Skip to content

Commit

Permalink
Getting in more tests and less warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ldecicco-USGS committed Aug 3, 2017
1 parent 64f1a53 commit ca2c759
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 5 deletions.
3 changes: 2 additions & 1 deletion R/plotFluxHist.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@
#' yearEnd <- 2010
#' eList <- Choptank_eList
#' # Water year:
#' \dontrun{
#' plotFluxHist(eList)
#' plotFluxHist(eList, yearStart, yearEnd, fluxUnit = 1)
#' plotFluxHist(eList, yearStart, yearEnd, fluxUnit = 'kgDay')
#' # Graphs consisting of Jun-Aug
#' eList <- setPA(eList, paStart=6,paLong=3)
#' plotFluxHist(eList)
#' \dontrun{
#'
#' # Flow normalized (excluding extremes from 2003-04):
#' yearVector <- c(1980:2002, 2005:2015)
#' plotFluxHist(eList, flowNormYears=yearVector)
Expand Down
2 changes: 2 additions & 0 deletions man/estFNyears.Rd

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

4 changes: 3 additions & 1 deletion man/plotConcHist.Rd

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

2 changes: 2 additions & 0 deletions man/plotFluxHist.Rd

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

2 changes: 2 additions & 0 deletions man/tableChange.Rd

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

7 changes: 5 additions & 2 deletions man/tableChangeSingle.Rd

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

2 changes: 2 additions & 0 deletions man/tableResults.Rd

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

20 changes: 19 additions & 1 deletion tests/testthat/tests_flow_normalization.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,22 @@ test_that("setupYears", {
"Conc [mg/L]","FN Conc [mg/L]",
"Flux [kg/day]","FN Flux [kg/day]")))

})
eList <- Choptank_eList
tFC <- tableFlowChange(eList, istat=5, yearPoints=c(1985,1990,1995,2001,2005,2009))
expect_true(all(names(tFC) %in% c("year1","year2","change[cfs]","slope[cfs/yr]",
"change[%]","slope[%/yr]")))
expect_equal(tFC$`change[cfs]`[1], 7.5)
expect_equal(tFC$`slope[cfs/yr]`[1], 1.5)
expect_equal(tFC$`change[%]`[1], 6.5)
expect_equal(tFC$`slope[%/yr]`[1], 1.3)

printReturn <- printSeries(eList, 5)
expect_true(all(names(printReturn) %in% c("years","qActual","qSmooth")))

expect_equal(printReturn$qActual[2], 78.3)
expect_equal(printReturn$qSmooth[2], 109)

expect_equal(setSeasonLabelByUser(), "Water Year")
expect_equal(setSeasonLabelByUser(paStartInput = 12,paLongInput = 3), "Season Consisting of Dec Jan Feb")
})

62 changes: 62 additions & 0 deletions tests/testthat/tests_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,46 @@ test_that("other plot functions don't error", {
expect_silent(plotFluxPred(eList))
expect_true(dev_start + 1 == dev.cur())

graphics.off()
dev_start <- dev.cur()
expect_silent(plotQTimeDaily(eList))
expect_true(dev_start + 1 == dev.cur())

graphics.off()
dev_start <- dev.cur()
expect_silent(plotFluxQ(eList))
expect_true(dev_start + 1 == dev.cur())

graphics.off()
dev_start <- dev.cur()
expect_silent(plotFlowSingle(eList, istat = 1))
expect_true(dev_start + 1 == dev.cur())

graphics.off()
dev_start <- dev.cur()
expect_silent(plotFour(eList))
expect_true(dev_start + 1 == dev.cur())

graphics.off()
dev_start <- dev.cur()
expect_silent(plotFour(eList))
expect_true(dev_start + 1 == dev.cur())

graphics.off()
dev_start <- dev.cur()
expect_silent(plot1of15(eList, yearStart = 1995, yearEnd = 2005, qf = 1))
expect_true(dev_start + 1 == dev.cur())

graphics.off()
dev_start <- dev.cur()
expect_silent(plotSDLogQ(eList))
expect_true(dev_start + 1 == dev.cur())

graphics.off()
dev_start <- dev.cur()
expect_silent(plot15(eList = eList, yearStart = 1995, yearEnd = 2005))
expect_true(dev_start + 1 == dev.cur())

graphics.off()
dev_start <- dev.cur()
expect_silent(plotResidPred(eList))
Expand Down Expand Up @@ -307,4 +347,26 @@ test_that("flexPlotAddOn functions properly", {
"The number of segments exceed the length of the color palette. Supply custom palette of length 32")
expect_true(dev_start + 1 == dev.cur())

startBlank <- "1995-01-01"
endBlank <- "2005-01-01"

blank_eList <- blankTime(eList, startBlank, endBlank)
expect_is(blank_eList, "egret")
blank_daily <- getDaily(blank_eList)
expect_true(all(is.na(blank_daily$FNConc[blank_daily$Date > startBlank &
blank_daily$Date < endBlank])))

not_blank <- getDaily(eList)
expect_false(all(is.na(not_blank$FNConc[not_blank$Date > startBlank &
not_blank$Date < endBlank])))

expect_output(printFluxUnitCheatSheet(),
"The following codes apply to the fluxUnit list", ignore.case = TRUE)

expect_output(printqUnitCheatSheet(),
"The following codes apply to the qUnit list:", ignore.case = TRUE)

bias <- fluxBiasStat(localSample = eList$Sample)
rounded <- as.numeric(signif(bias))
expect_equal(rounded, c(-0.0235532,-0.0235429,-0.023548))
})

0 comments on commit ca2c759

Please sign in to comment.