Skip to content

Commit

Permalink
Added few new tests (windrose, plot)
Browse files Browse the repository at this point in the history
  • Loading branch information
retostauffer committed Aug 12, 2019
1 parent 2521508 commit 5b5a34b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions tests/testthat/test_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ test_that("Testing plot.foehnix function", {
expect_silent(plotfun(mod0, which = 1:2, ask = FALSE))
expect_silent(plotfun(mod1, which = 1:2, ask = FALSE))

# Posterior plot with custom freq/breaks
expect_silent(plotfun(mod1, which = "post"))
expect_silent(plotfun(mod1, which = "post", freq = TRUE))
expect_silent(plotfun(mod1, which = "post", freq = FALSE))
expect_error(plotfun(mod1, which = "post", freq = "wrong"))
expect_silent(plot(mod1, which = "post", breaks = seq(0, 1, by = 0.05)))
expect_silent(plot(mod1, which = "post", breaks = c(0, 0.2, 0.4, 0.9, 1.0)))

# Setting log to FALSE
expect_silent(plotfun(mod0, log = FALSE, ask = FALSE))
expect_silent(plotfun(mod1, log = FALSE, ask = FALSE))
Expand Down
6 changes: 5 additions & 1 deletion tests/testthat/test_windrose.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ test_that("Testing wind rose plot functionality (basic type)", {
# Wind speed < 0
expect_error(windrosefun(dd = c(10,180), ff = c(-3,1)))


# Loading some data
expect_silent(data <- demodata("ellboegen"))

Expand All @@ -44,6 +45,9 @@ test_that("Testing wind rose plot functionality (basic type)", {
expect_identical(dim(res$tab), c(length(res$dd.breaks), length(res$ff.breaks)) - 1L)
expect_true(is.null(res$counts))

# Custom breaks
expect_silent(windrosefun(data, breaks = seq(0, 30, by = 2.5)))
expect_warning(windrosefun(data, breaks = seq(0, 10, by = 2.5)))

# Second: the histogram plot
expect_silent(res <- windrosefun(as.numeric(data$dd), as.numeric(data$ff),
Expand All @@ -63,7 +67,7 @@ test_that("Testing wind rose plot functionality (basic type)", {
copy <- data
names(copy)[grep("^ff$", names(copy))] <- "wind_spd"
names(copy)[grep("^dd$", names(copy))] <- "wind_dir"
expect_silent(windrosefun(copy, var.ff = "wind_spd", var.dd = "wind_dir"))
expect_silent(windrosefun(copy, ffvar = "wind_spd", ddvar = "wind_dir"))

})

Expand Down

0 comments on commit 5b5a34b

Please sign in to comment.