Running 'testthat.R' [222s/301s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
  > library(testthat)
  > library(windfarmGA)
  > 
  > 
  > test_check("windfarmGA")
  ........$Input_Data
                         [,1]                                                                                                                 
  Rotorradius            "30"                                                                                                                 
  Number of turbines     "12"                                                                                                                 
  Grid Shape Factor      "5"                                                                                                                  
  Iterations             "1"                                                                                                                  
  Mutation Rate          "0.008"                                                                                                              
  Percentage of Polygon  "1"                                                                                                                  
  Topographie            "TRUE"                                                                                                               
  Elitarism              "TRUE"                                                                                                               
  Selection Method       "FIX"                                                                                                                
  Trim Force Method Used "FALSE"                                                                                                              
  Crossover Method Used  "EQU"                                                                                                                
  Reference Height       "100"                                                                                                                
  Rotor Height           "100"                                                                                                                
  Resolution             "150"                                                                                                                
  Parallel Processing    "FALSE"                                                                                                              
  Number Clusters        "2"                                                                                                                  
  Active Weibull         "FALSE"                                                                                                              
  Grid Method            "Rectangular"                                                                                                        
  Projection             "+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000\n    +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
  
  $Windspeed_Data
    ws wd
  1 12  0
  
  Topography and orography are taken into account.
  trying URL 'http://github.com/YsoSirius/windfarm_data/raw/master/clc.zip'
  Content type 'application/zip' length 72773076 bytes (69.4 MB)
  ==================================================
  downloaded 69.4 MB
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  windfarmGA
   --- call from context --- 
  barometric_height(data, height, po, ro)
   --- call from argument --- 
  if (class(data) != "data.frame") {
      data <- data.frame(data)
  }
   --- R stacktrace ---
  where 1: barometric_height(data, height, po, ro)
  where 2 at testthat/test_ga_func.R#31: BaroHoehe(data)
  where 3: eval(code, test_env)
  where 4: eval(code, test_env)
  where 5: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 6: doTryCatch(return(expr), name, parentenv, handler)
  where 7: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 8: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 9: doTryCatch(return(expr), name, parentenv, handler)
  where 10: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 11: tryCatchList(expr, classes, parentenv, handlers)
  where 12: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 13: test_code(desc, code, env = parent.frame())
  where 14 at testthat/test_ga_func.R#13: test_that("Test Genetic Algorithm Function", {
      Polygon1 <- Polygon(rbind(c(0, 0), c(0, 2000), c(2000, 2000), 
          c(2000, 0)))
      Polygon1 <- Polygons(list(Polygon1), 1)
      Polygon1 <- SpatialPolygons(list(Polygon1))
      Projection <- "+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000\n  +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
      proj4string(Polygon1) <- CRS(Projection)
      Polygon2 <- Polygon(rbind(c(0, 0), c(0, 3500), c(1500, 2000), 
          c(2000, 0)))
      Polygon2 <- Polygons(list(Polygon2), 1)
      Polygon2 <- SpatialPolygons(list(Polygon2))
      Projection <- "+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000\n  +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
      proj4string(Polygon2) <- CRS(Projection)
      data <- matrix(seq(0, 5000, 500))
      res <- BaroHoehe(data)
      expect_false(anyNA(res))
      res1 <- BaroHoehe(data[, 1])
      expect_false(anyNA(res1))
      expect_true(all.equal(res, res1))
      data <- data.frame(id = sample(1:10, length(seq(0, 5000, 
          500)), replace = TRUE), elev = seq(0, 5000, 500))
      res2 <- BaroHoehe(data = data, "elev")
      expect_false(anyNA(res2))
      expect_true(all.equal(res2, res1))
      expect_error(BaroHoehe(data = data))
      rm(data, res, res1, res2)
      Grid <- GridFilter(shape = Polygon1, resol = 200, prop = 1)
      expect_is(Grid[[1]], "matrix")
      expect_is(Grid[[2]], "SpatialPolygonsDataFrame")
      expect_false(anyNA(Grid[[1]]))
      Grid <- GridFilter(shape = Polygon1, resol = 200, prop = 0.1)
      expect_is(Grid[[1]], "matrix")
      expect_is(Grid[[2]], "SpatialPolygonsDataFrame")
      expect_false(anyNA(Grid[[1]]))
      Grid <- GridFilter(shape = Polygon1, resol = 500, prop = 0.1)
      expect_is(Grid[[1]], "matrix")
      expect_is(Grid[[2]], "SpatialPolygonsDataFrame")
      expect_false(anyNA(Grid[[1]]))
      Grid <- GridFilter(shape = Polygon1, resol = 500, prop = 0)
      expect_is(Grid[[1]], "matrix")
      expect_is(Grid[[2]], "SpatialPolygonsDataFrame")
      expect_false(anyNA(Grid[[1]]))
      Grid <- GridFilter(shape = Polygon1, resol = 300, prop = 0, 
          plotGrid = TRUE)
      expect_is(Grid[[1]], "matrix")
      expect_is(Grid[[2]], "SpatialPolygonsDataFrame")
      expect_false(anyNA(Grid[[1]]))
      quiet(expect_error(GridFilter(shape = Polygon1, resol = 1e+06, 
          prop = -1)))
      Grid <- GridFilter(shape = Polygon2, resol = 300, prop = 100)
      expect_is(Grid[[1]], "matrix")
      expect_is(Grid[[2]], "SpatialPolygonsDataFrame")
      expect_false(anyNA(Grid[[1]]))
      Grid1 <- GridFilter(shape = Polygon2, resol = 300, prop = 0.1)
      expect_is(Grid1[[1]], "matrix")
      expect_is(Grid1[[2]], "SpatialPolygonsDataFrame")
      expect_false(anyNA(Grid1[[1]]))
      expect_true(nrow(Grid1[[1]]) > nrow(Grid[[1]]))
      expect_false(identical(Grid[[2]]@bbox, Grid1[[2]]@bbox))
      Grid1 <- GridFilter(shape = Polygon2, resol = 300, prop = -100)
      expect_is(Grid1[[1]], "matrix")
      expect_is(Grid1[[2]], "SpatialPolygonsDataFrame")
      expect_false(anyNA(Grid1[[1]]))
      expect_true(nrow(Grid1[[1]]) > nrow(Grid[[1]]))
      expect_false(identical(Grid[[2]]@bbox, Grid1[[2]]@bbox))
      rm(Grid1, Polygon2)
      HexGrid <- HexaTex(Polygon1, 100, FALSE)
      expect_is(HexGrid[[1]], "matrix")
      expect_is(HexGrid[[2]], "SpatialPolygons")
      expect_false(anyNA(HexGrid[[1]]))
      HexGrid <- HexaTex(Polygon1, 100, TRUE)
      expect_is(HexGrid[[1]], "matrix")
      expect_is(HexGrid[[2]], "SpatialPolygons")
      expect_false(anyNA(HexGrid[[1]]))
      HexGrid <- HexaTex(Polygon1, 200, FALSE)
      expect_is(HexGrid[[1]], "matrix")
      expect_is(HexGrid[[2]], "SpatialPolygons")
      expect_false(anyNA(HexGrid[[1]]))
      HexGrid <- HexaTex(Polygon1, 400.1, FALSE)
      expect_is(HexGrid[[1]], "matrix")
      expect_is(HexGrid[[2]], "SpatialPolygons")
      expect_false(anyNA(HexGrid[[1]]))
      HexGrid <- HexaTex(Polygon1, 1e+09, FALSE)
      expect_is(HexGrid[[1]], "matrix")
      expect_is(HexGrid[[2]], "SpatialPolygons")
      expect_false(anyNA(HexGrid[[1]]))
      rm(HexGrid)
      HexaGrid <- spatstat::hextess(windfarmGA:::owin_spatialPolygons(Polygon1), 
          s = 100)
      expect_true(class(HexaGrid)[1] == "tess")
      Hex2spdf <- tess2SPdf(HexaGrid)
      expect_is(Hex2spdf, "SpatialPolygons")
      rm(Hex2spdf, HexaGrid)
      startsel <- StartGA(Grid[[1]], n = 10, nStart = 20)
      expect_is(startsel, "list")
      expect_true(all(sapply(startsel, class) == "matrix"))
      expect_true(all(sapply(startsel, nrow) == 10))
      expect_true(all(sapply(startsel, ncol) == 4))
      expect_output(str(startsel), "List of 20")
      expect_false(any(unlist(sapply(startsel, is.na))))
      quiet(expect_error(StartGA(Grid[[1]][1:10, ], n = 10, nStart = 20)))
      quiet(expect_error(StartGA(Grid[[1]][1:10, ], n = 7, nStart = 20)))
      startsel <- StartGA(Grid[[1]], n = 20, nStart = 25)
      expect_is(startsel, "list")
      expect_true(all(sapply(startsel, class) == "matrix"))
      expect_true(all(sapply(startsel, nrow) == 20))
      expect_true(all(sapply(startsel, ncol) == 4))
      expect_output(str(startsel), "List of 25")
      expect_false(any(unlist(sapply(startsel, is.na))))
      startsel <- StartGA(Grid[[1]], n = 20, nStart = 100)
      expect_is(startsel, "list")
      expect_true(all(sapply(startsel, class) == "matrix"))
      expect_true(all(sapply(startsel, nrow) == 20))
      expect_true(all(sapply(startsel, ncol) == 4))
      expect_output(str(startsel), "List of 100")
      expect_false(any(unlist(sapply(startsel, is.na))))
      startsel <- StartGA(Grid[[1]], n = 20, nStart = 300)
      expect_is(startsel, "list")
      expect_true(all(sapply(startsel, class) == "matrix"))
      expect_true(all(sapply(startsel, nrow) == 20))
      expect_true(all(sapply(startsel, ncol) == 4))
      expect_output(str(startsel), "List of 300")
      expect_false(any(unlist(sapply(startsel, is.na))))
      startsel <- StartGA(Grid[[1]], n = 10, nStart = 20)
      expect_is(startsel, "list")
      expect_true(all(sapply(startsel, class) == "matrix"))
      expect_true(all(sapply(startsel, nrow) == 10))
      expect_true(all(sapply(startsel, ncol) == 4))
      expect_output(str(startsel), "List of 20")
      expect_false(any(unlist(sapply(startsel, is.na))))
      wind <- data.frame(ws = 12, wd = 0)
      wind <- list(wind, probab = 100)
      fit <- fitness(selection = startsel, referenceHeight = 100, 
          RotorHeight = 100, SurfaceRoughness = 0.3, Polygon = Polygon1, 
          resol1 = 200, rot = 20, dirspeed = wind, srtm_crop = "", 
          topograp = FALSE, cclRaster = "")
      expect_output(str(fit), "List of 20")
      expect_true(all(sapply(fit, nrow) == 10))
      expect_false(any(unlist(sapply(fit, is.na))))
      expect_false(any(unlist(do.call("rbind", fit)[, -c(1, 2)] < 
          0)))
      fit1 <- fitness(selection = startsel, referenceHeight = 100, 
          RotorHeight = 100, SurfaceRoughness = 0.3, Polygon = Polygon1, 
          resol1 = 200, rot = 20, dirspeed = wind, topograp = FALSE)
      expect_output(str(fit1), "List of 20")
      expect_true(all(sapply(fit1, nrow) == 10))
      expect_false(any(unlist(sapply(fit1, is.na))))
      expect_false(any(unlist(do.call("rbind", fit1)[, -c(1, 2)] < 
          0)))
      rm(fit1)
      allparks <- do.call("rbind", fit)
      selec6best <- selection1(fit, Grid[[1]], 2, TRUE, 6, "VAR")
      expect_output(str(selec6best), "List of 2")
      expect_false(any(unlist(sapply(selec6best, is.na))))
      expect_true(all(unlist(selec6best[[1]][, -1]) %in% c(0, 1)))
      expect_true(all(selec6best[[2]][, -1] > 0))
      rm(selec6best)
      fitNA <- fit
      fitNA[[1]][, "Parkfitness"] <- NA
      a <- lapply(1:length(fitNA), function(i) {
          fitNA[[i]][, "Parkfitness"] <<- NA
      })
      rm(a)
      quiet(expect_error(selection1(fitNA, Grid[[1]], 2, TRUE, 
          6, "VAR")))
      selec6best <- selection1(fit, Grid[[1]], teil = 1, TRUE, 
          6, "FIX")
      expect_output(str(selec6best), "List of 2")
      expect_false(any(unlist(sapply(selec6best, is.na))))
      expect_true(all(unlist(selec6best[[1]][, -1]) %in% c(0, 1)))
      expect_true(all(selec6best[[2]][, -1] > 0))
      rm(selec6best)
      selec6best <- selection1(fit, Grid[[1]], 2, TRUE, 6, "FIX")
      expect_output(str(selec6best), "List of 2")
      expect_false(any(unlist(sapply(selec6best, is.na))))
      expect_true(all(unlist(selec6best[[1]][, -1]) %in% c(0, 1)))
      expect_true(all(selec6best[[2]][, -1] > 0))
      rm(selec6best)
      selec6best <- selection1(fit, Grid[[1]], 2, TRUE, 6, "FIX")
      expect_output(str(selec6best), "List of 2")
      expect_false(any(unlist(sapply(selec6best, is.na))))
      expect_true(all(unlist(selec6best[[1]][, -1]) %in% c(0, 1)))
      expect_true(all(selec6best[[2]][, -1] > 0))
      rm(selec6best)
      selec6best <- quiet(selection1(fit, Grid[[1]], 4, FALSE, 
          6, selstate = "VAR", verbose = TRUE))
      expect_output(str(selec6best), "List of 2")
      expect_false(any(unlist(sapply(selec6best, is.na))))
      expect_true(all(unlist(selec6best[[1]][, -1]) %in% c(0, 1)))
      expect_true(all(selec6best[[2]][, -1] > 0))
      rm(selec6best)
      selec6best <- quiet(selection1(fit, Grid[[1]], 4, FALSE, 
          6, "FIX", verbose = TRUE))
      expect_output(str(selec6best), "List of 2")
      expect_false(any(unlist(sapply(selec6best, is.na))))
      expect_true(all(unlist(selec6best[[1]][, -1]) %in% c(0, 1)))
      expect_true(all(selec6best[[2]][, -1] > 0))
      selec6best <- quiet(selection1(fit, Grid[[1]], 4, TRUE, 6, 
          "FIX", verbose = TRUE))
      expect_output(str(selec6best), "List of 2")
      expect_false(any(unlist(sapply(selec6best, is.na))))
      expect_true(all(unlist(selec6best[[1]][, -1]) %in% c(0, 1)))
      expect_true(all(selec6best[[2]][, -1] > 0))
      crossOut <- quiet(crossover1(selec6best, 2, uplimit = 300, 
          crossPart = "RAN", verbose = TRUE))
      expect_output(str(crossOut), "num")
      expect_false(any(is.na(crossOut)))
      expect_true(all(crossOut %in% c(0, 1)))
      rm(crossOut)
      crossOut <- crossover1(selec6best, 7, uplimit = 500, crossPart = "RAN")
      expect_output(str(crossOut), "num")
      expect_false(any(is.na(crossOut)))
      expect_true(all(crossOut %in% c(0, 1)))
      rm(crossOut)
      crossOut <- quiet(crossover1(se6 = selec6best, u = 6, uplimit = 100, 
          crossPart = "EQU", seed = 105, verbose = TRUE))
      expect_output(str(crossOut), "num")
      expect_false(any(is.na(crossOut)))
      expect_true(all(crossOut %in% c(0, 1)))
      crossOut1 <- crossover1(se6 = selec6best, u = 3, uplimit = 300, 
          crossPart = "EQU", seed = 105)
      crossOut2 <- crossover1(se6 = selec6best, u = 3, uplimit = 300, 
          crossPart = "EQU", seed = 105)
      expect_true(all.equal(crossOut1, crossOut2, tolerance = 2))
      expect_output(str(crossOut1), "num")
      expect_false(any(is.na(crossOut1)))
      expect_true(all(crossOut1 %in% c(0, 1)))
      rm(crossOut, crossOut1)
      crossOut <- crossover1(se6 = selec6best, u = 7, uplimit = 500, 
          crossPart = "RAN", seed = 105)
      expect_output(str(crossOut), "num")
      expect_false(any(is.na(crossOut)))
      expect_true(all(crossOut %in% c(0, 1)))
      rm(crossOut)
      expect_error(crossover1(se6 = selec6best, u = 7, uplimit = 500, 
          crossPart = "something"))
      crossOut <- crossover1(selec6best, 3, uplimit = 300, crossPart = "EQU")
      expect_output(str(crossOut), "num")
      expect_false(any(is.na(crossOut)))
      expect_true(all(crossOut %in% c(0, 1)))
      mut <- mutation(a = crossOut, p = 0.3)
      expect_output(str(mut), "num")
      expect_false(any(is.na(mut)))
      expect_true(all(mut %in% c(0, 1)))
      mut <- mutation(a = crossOut, p = 0.1)
      expect_output(str(mut), "num")
      expect_false(any(is.na(mut)))
      expect_true(all(mut %in% c(0, 1)))
      mut <- mutation(a = crossOut, p = 1)
      expect_output(str(mut), "num")
      expect_false(any(is.na(mut)))
      expect_true(all(mut %in% c(0, 1)))
      mut <- mutation(a = crossOut, p = 100)
      expect_output(str(mut), "num")
      expect_false(any(is.na(mut)))
      expect_true(all(mut %in% c(0, 1)))
      mut <- mutation(a = crossOut, p = -1)
      expect_output(str(mut), "num")
      expect_false(any(is.na(mut)))
      expect_true(all(mut %in% c(0, 1)))
      mut <- mutation(a = crossOut, p = -1, seed = 104)
      mut1 <- mutation(a = crossOut, p = -1, seed = 104)
      expect_true(identical(mut, mut1))
      mut <- mutation(a = crossOut, p = 5e-04)
      expect_output(str(mut), "num")
      expect_false(any(is.na(mut)))
      expect_true(all(mut %in% c(0, 1)))
      mut1 <- trimton(mut = mut, nturb = 1, allparks = allparks, 
          nGrids = nrow(Grid[[1]]), trimForce = FALSE)
      expect_output(str(mut1), "num")
      expect_false(any(is.na(mut1)))
      expect_true(all(mut1 %in% c(0, 1)))
      expect_true(all(colSums(mut1) == 1))
      expect_true(all(dim(mut) == dim(mut1)))
      rm(mut1)
      mut1 <- trimton(mut = mut, nturb = min(colSums(mut)), allparks = allparks, 
          nGrids = nrow(Grid[[1]]), trimForce = FALSE)
      expect_output(str(mut1), "num")
      expect_false(any(is.na(mut1)))
      expect_true(all(mut1 %in% c(0, 1)))
      expect_true(all(colSums(mut1) == min(colSums(mut))))
      expect_true(all(dim(mut) == dim(mut1)))
      rm(mut1)
      mut1 <- trimton(mut = mut, nturb = 10, allparks = allparks, 
          nGrids = nrow(Grid[[1]]), trimForce = FALSE)
      expect_output(str(mut1), "num")
      expect_false(any(is.na(mut1)))
      expect_true(all(mut1 %in% c(0, 1)))
      expect_true(all(colSums(mut1) == 10))
      expect_true(all(dim(mut) == dim(mut1)))
      mut1 <- trimton(mut = mut, nturb = 5, allparks = allparks, 
          nGrids = nrow(Grid[[1]]), trimForce = TRUE)
      expect_output(str(mut1), "num")
      expect_false(any(is.na(mut1)))
      expect_true(all(mut1 %in% c(0, 1)))
      expect_true(all(colSums(mut1) == 5))
      expect_true(all(dim(mut) == dim(mut1)))
      rm(mut1)
      mut1 <- trimton(mut = mut, nturb = 1, allparks = allparks, 
          nGrids = nrow(Grid[[1]]), trimForce = TRUE)
      expect_output(str(mut1), "num")
      expect_false(any(is.na(mut1)))
      expect_true(all(mut1 %in% c(0, 1)))
      expect_true(all(colSums(mut1) == 1))
      expect_true(all(dim(mut) == dim(mut1)))
      rm(mut1)
      mut1 <- trimton(mut = mut, nturb = min(colSums(mut)), allparks = allparks, 
          nGrids = nrow(Grid[[1]]), trimForce = TRUE)
      expect_output(str(mut1), "num")
      expect_false(any(is.na(mut1)))
      expect_true(all(mut1 %in% c(0, 1)))
      expect_true(all(colSums(mut1) == min(colSums(mut))))
      expect_true(all(dim(mut) == dim(mut1)))
      rm(mut1)
      mut1 <- trimton(mut = mut, nturb = 20, allparks = allparks, 
          nGrids = nrow(Grid[[1]]), trimForce = TRUE)
      expect_output(str(mut1), "num")
      expect_false(any(is.na(mut1)))
      expect_true(all(mut1 %in% c(0, 1)))
      expect_true(all(colSums(mut1) == 20))
      expect_true(all(dim(mut) == dim(mut1)))
      mut1 <- trimton(mut = mut, nturb = 20, allparks = allparks, 
          nGrids = nrow(Grid[[1]]), trimForce = TRUE, seed = 104)
      mut2 <- trimton(mut = mut, nturb = 20, allparks = allparks, 
          nGrids = nrow(Grid[[1]]), trimForce = TRUE, seed = 104)
      expect_true(identical(mut1, mut2))
      mut1 <- trimton(mut = mut, nturb = 20, allparks = allparks, 
          nGrids = nrow(Grid[[1]]), trimForce = FALSE, seed = 234)
      mut2 <- trimton(mut = mut, nturb = 20, allparks = allparks, 
          nGrids = nrow(Grid[[1]]), trimForce = FALSE, seed = 234)
      expect_true(identical(mut1, mut2))
      mut1 <- trimton(mut = mut, nturb = 5, allparks = allparks, 
          nGrids = nrow(Grid[[1]]), trimForce = TRUE, seed = 300)
      mut2 <- trimton(mut = mut, nturb = 5, allparks = allparks, 
          nGrids = nrow(Grid[[1]]), trimForce = TRUE, seed = 300)
      expect_true(identical(mut1, mut2))
      mut1 <- trimton(mut = mut, nturb = 5, allparks = allparks, 
          nGrids = nrow(Grid[[1]]), trimForce = FALSE, seed = 234)
      mut2 <- trimton(mut = mut, nturb = 5, allparks = allparks, 
          nGrids = nrow(Grid[[1]]), trimForce = FALSE, seed = 234)
      expect_true(identical(mut1, mut2))
      getRectV <- getRects(mut1, Grid[[1]])
      expect_is(getRectV, "list")
      expect_true(all(sapply(getRectV, class) == "matrix"))
      expect_true(all(sapply(getRectV, ncol) == 3))
      expect_false(any(unlist(sapply(getRectV, is.na))))
      expect_true(all(sapply(getRectV, colnames) %in% c("ID", "X", 
          "Y")))
      fit <- fitness(selection = getRectV, referenceHeight = 100, 
          RotorHeight = 100, SurfaceRoughness = 0.3, Polygon = Polygon1, 
          resol1 = 200, rot = 20, dirspeed = wind, srtm_crop = "", 
          topograp = FALSE, cclRaster = "")
      expect_is(fit, "list")
      expect_true(length(fit) == length(getRectV))
      expect_false(any(unlist(sapply(fit, is.na))))
      expect_false(any(unlist(do.call("rbind", fit)[, -c(1, 2)] < 
          0)))
  })
  where 15: eval(code, test_env)
  where 16: eval(code, test_env)
  where 17: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 18: doTryCatch(return(expr), name, parentenv, handler)
  where 19: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 20: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 21: doTryCatch(return(expr), name, parentenv, handler)
  where 22: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 23: tryCatchList(expr, classes, parentenv, handlers)
  where 24: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 25: test_code(NULL, exprs, env)
  where 26: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 27: force(code)
  where 28: doWithOneRestart(return(expr), restart)
  where 29: withOneRestart(expr, restarts[[1L]])
  where 30: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 31: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter, 
      {
          reporter$start_file(basename(path))
          lister$start_file(basename(path))
          source_file(path, new.env(parent = env), chdir = TRUE, 
              wrap = wrap)
          reporter$.end_context()
          reporter$end_file()
      })
  where 32: FUN(X[[i]], ...)
  where 33: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 34: force(code)
  where 35: doWithOneRestart(return(expr), restart)
  where 36: withOneRestart(expr, restarts[[1L]])
  where 37: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 38: with_reporter(reporter = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 39: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 40: test_dir(path = test_path, reporter = reporter, env = env, filter = filter, 
      ..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning, 
      wrap = wrap)
  where 41: test_package_dir(package = package, test_path = test_path, filter = filter, 
      reporter = reporter, ..., stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 42: test_check("windfarmGA")
  
   --- value of length: 2 type: logical ---
  [1] TRUE TRUE
   --- function from context --- 
  function (data, height, po = 101325, ro = 1.225) 
  {
      if (is.numeric(data) || (ncol(data)) == 1) {
          ph <- as.numeric(po * exp(-data * 0.0001252))
          rh <- as.numeric(ro * exp(-data * 0.0001252))
          Th <- as.numeric(288.15 - ((6.5 * data)/1000))
      }
      else {
          if (missing(height)) {
              stop("Height column not given.")
          }
          data <- data[, height]
          ph <- po * exp(-data * 0.0001252)
          rh <- ro * exp(-data * 0.0001252)
          Th <- 288.15 - ((6.5 * data)/1000)
      }
      if (class(data) != "data.frame") {
          data <- data.frame(data)
      }
      colnames(data) <- "Height"
      celsius <- as.numeric(Th - 273.15)
      data$ph <- ph
      data$rh <- rh
      data$tempK <- Th
      data$tempC <- celsius
      return(data)
  }
  <bytecode: 0xd4d0f60>
  <environment: namespace:windfarmGA>
   --- function search by body ---
  Function barometric_height in namespace windfarmGA has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 1. Error: Test Genetic Algorithm Function (@test_ga_func.R#31)  -------------
  the condition has length > 1
  Backtrace:
   1. windfarmGA::BaroHoehe(data)
   2. windfarmGA::barometric_height(data, height, po, ro)
  
  .[1] "plot_result: Plot the 'best' Individuals of the GA:"
  N different optimal configurations: 98 
  Amount duplicates: 102
  Plot  1  Best Energy Solution:
  Press [enter] to continue
  [1] "plot_evolution: Plot the Evolution of the Efficiency and Energy Values:"
  [1] "plot_parkfitness: Plot the Influence of Population Size, Selection, Crossover, Mutation:"
  Press [enter] to continue
  [1] "plot_fitness_evolution: Plot the Changes in Fitness Values:"
  Press [enter] to continue
  [1] "plot_cloud: Plot all individual Values of the whole Evolution:"
  Press [enter] to continue
  [1] "plot_heatmap: Plot a Heatmap of all Grid Cells:"
  [inverse distance weighted interpolation]
  Cannot plot option 2,3,4,5. 
   Only option 1,6 are available.[1] "plot_result: Plot the 'best' Individuals of the GA:"
  N different optimal configurations: 3 
  Amount duplicates: 0
  Plot  1  Best Energy Solution:
  Press [enter] to continue
  [1] "plot_heatmap: Plot a Heatmap of all Grid Cells:"
  [inverse distance weighted interpolation]
  Cannot plot option 2,3,4,5. 
   Only option 1,6 are available.[1] "plot_result: Plot the 'best' Individuals of the GA:"
  N different optimal configurations: 3 
  Amount duplicates: 0
  Plot  1  Best Energy Solution:
  Press [enter] to continue
  [1] "plot_heatmap: Plot a Heatmap of all Grid Cells:"
  [inverse distance weighted interpolation]
  [1] "plot_result: Plot the 'best' Individuals of the GA:"
  N different optimal configurations: 9 
  Amount duplicates: 1
  Plot  2  Best Energy Solution:
  
  Plot  1  Best Energy Solution:
  Press [enter] to continue
  [1] "plot_evolution: Plot the Evolution of the Efficiency and Energy Values:"
  [1] "plot_parkfitness: Plot the Influence of Population Size, Selection, Crossover, Mutation:"
  Press [enter] to continue
  [1] "plot_fitness_evolution: Plot the Changes in Fitness Values:"
  Press [enter] to continue
  [1] "plot_cloud: Plot all individual Values of the whole Evolution:"
  Press [enter] to continue
  [1] "plot_heatmap: Plot a Heatmap of all Grid Cells:"
  [inverse distance weighted interpolation]
  -- 2. Failure: Test Plotting Functions (@test_plots.R#167)  --------------------
  class(cloud_res) == "matrix" isn't true.
  
  -- 3. Failure: Test Plotting Functions (@test_plots.R#172)  --------------------
  class(cloud_res) == "matrix" isn't true.
  
  [inverse distance weighted interpolation]
  [inverse distance weighted interpolation]
  [inverse distance weighted interpolation]
  Maximum possible number for 'which':  10.$Input_Data
                         [,1]                                                                                                                 
  Rotorradius            "30"                                                                                                                 
  Number of turbines     "12"                                                                                                                 
  Grid Shape Factor      "5"                                                                                                                  
  Iterations             "1"                                                                                                                  
  Mutation Rate          "0.008"                                                                                                              
  Percentage of Polygon  "1"                                                                                                                  
  Topographie            "TRUE"                                                                                                               
  Elitarism              "TRUE"                                                                                                               
  Selection Method       "FIX"                                                                                                                
  Trim Force Method Used "FALSE"                                                                                                              
  Crossover Method Used  "EQU"                                                                                                                
  Reference Height       "100"                                                                                                                
  Rotor Height           "100"                                                                                                                
  Resolution             "150"                                                                                                                
  Parallel Processing    "FALSE"                                                                                                              
  Number Clusters        "2"                                                                                                                  
  Active Weibull         "FALSE"                                                                                                              
  Grid Method            "Rectangular"                                                                                                        
  Projection             "+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000\n    +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
  
  $Windspeed_Data
    ws wd
  1 12  0
  
  Topography and orography are taken into account.
  trying URL 'http://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/TIFF/srtm_39_03.zip'
  Content type 'application/x-zip-compressed' length 37627843 bytes (35.9 MB)
  ==================================================
  downloaded 35.9 MB
  
  
  Start Genetic Algorithm ...
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  windfarmGA
   --- call from context --- 
  barometric_height(matrix(turb_elev), turb_elev)
   --- call from argument --- 
  if (class(data) != "data.frame") {
      data <- data.frame(data)
  }
   --- R stacktrace ---
  where 1: barometric_height(matrix(turb_elev), turb_elev)
  where 2: calculate_energy(sel = selection[[i]], referenceHeight = referenceHeight, 
      RotorHeight = RotorHeight, SurfaceRoughness = SurfaceRoughness, 
      wnkl = 20, distanz = 1e+05, polygon1 = Polygon, resol = resol1, 
      RotorR = rot, dirSpeed = dirspeed, srtm_crop = srtm_crop, 
      topograp = topograp, cclRaster = cclRaster, weibull = weibull)
  where 3: fitness(selection = startsel, referenceHeight = referenceHeight, 
      RotorHeight = RotorHeight, SurfaceRoughness = SurfaceRoughness, 
      Polygon = Polygon1, resol1 = resol2, rot = Rotor, dirspeed = winddata, 
      srtm_crop = srtm_crop, topograp = topograp, cclRaster = cclRaster, 
      weibull = estim_speed_raster, Parallel = Parallel, numCluster = numCluster)
  where 4: genetic_algorithm(Polygon1, GridMethod, Rotor, n, fcrR, referenceHeight, 
      RotorHeight, SurfaceRoughness, Proportionality, iteration, 
      mutr, vdirspe, topograp, elitism, nelit, selstate, crossPart1, 
      trimForce, Projection, sourceCCL, sourceCCLRoughness, weibull, 
      weibullsrc, Parallel, numCluster, verbose, plotit)
  where 5 at testthat/test_terrain.R#39: genAlgo(Polygon1 = sp_polygon, n = 12, iteration = 1, vdirspe = data.in, 
      Rotor = 30, RotorHeight = 100, topograp = TRUE, verbose = TRUE, 
      plotit = TRUE)
  where 6: eval(code, test_env)
  where 7: eval(code, test_env)
  where 8: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 9: doTryCatch(return(expr), name, parentenv, handler)
  where 10: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 11: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 12: doTryCatch(return(expr), name, parentenv, handler)
  where 13: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 14: tryCatchList(expr, classes, parentenv, handlers)
  where 15: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 16: test_code(desc, code, env = parent.frame())
  where 17 at testthat/test_terrain.R#6: test_that("Test Terrain and Weibull Effects", {
      skip_on_appveyor()
      Projection <- "+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
      data.in <- data.frame(ws = 12, wd = 0)
      sp_polygon <- Polygon(rbind(c(4498482, 2668272), c(4498482, 
          2669343), c(4499991, 2669343), c(4499991, 2668272)))
      sp_polygon <- Polygons(list(sp_polygon), 1)
      sp_polygon <- SpatialPolygons(list(sp_polygon))
      proj4string(sp_polygon) <- CRS(Projection)
      resultrect <- genAlgo(Polygon1 = sp_polygon, n = 12, iteration = 1, 
          vdirspe = data.in, Rotor = 30, RotorHeight = 100, topograp = TRUE, 
          verbose = TRUE, plotit = TRUE)
      expect_true(nrow(resultrect) == 1)
      expect_is(resultrect, "matrix")
      expect_false(any(unlist(sapply(resultrect, is.na))))
      path <- paste0(system.file(package = "windfarmGA"), "/extdata/")
      sourceCCLRoughness <- paste0(path, "clc_legend.csv")
      resultrect <- genAlgo(Polygon1 = sp_polygon, n = 12, iteration = 1, 
          vdirspe = data.in, Rotor = 30, RotorHeight = 100, topograp = TRUE, 
          verbose = TRUE, plotit = TRUE, sourceCCL = "g100_06.tif", 
          sourceCCLRoughness = sourceCCLRoughness)
      expect_true(nrow(resultrect) == 1)
      expect_is(resultrect, "matrix")
      expect_false(any(unlist(sapply(resultrect, is.na))))
      DEM <- raster("srtm_39_03.tif")
      sp_polygonproj <- spTransform(sp_polygon, CRS(proj4string(DEM)))
      DEMcrop <- crop(DEM, sp_polygonproj)
      maxval <- max(values(DEMcrop))
      a_raster <- raster::calc(DEMcrop, function(x) (x/maxval) + 
          1)
      k_raster <- raster::calc(DEMcrop, function(x) (x/maxval) + 
          6)
      resultrect <- genAlgo(Polygon1 = sp_polygon, n = 12, iteration = 1, 
          vdirspe = data.in, Rotor = 30, RotorHeight = 100, verbose = TRUE, 
          weibull = TRUE, weibullsrc = list(k_raster, a_raster))
      expect_true(nrow(resultrect) == 1)
      expect_is(resultrect, "matrix")
      expect_false(any(unlist(sapply(resultrect, is.na))))
      resultrect <- genAlgo(Polygon1 = sp_polygon, n = 12, iteration = 1, 
          vdirspe = data.in, Rotor = 30, RotorHeight = 100, verbose = TRUE, 
          weibull = TRUE)
      expect_true(nrow(resultrect) == 1)
      expect_is(resultrect, "matrix")
      expect_false(any(unlist(sapply(resultrect, is.na))))
      f <- file()
      options(windfarmGA.connection = f)
      write(paste(rep(" ", 20), collapse = "\n"), f)
      resultrect <- windfarmGA(Polygon1 = sp_polygon, selstate = "FIX", 
          crossPart1 = "EQU", n = 12, iteration = 1, vdirspe = data.in, 
          Rotor = 30, RotorHeight = 100, verbose = TRUE, weibull = TRUE)
      options(windfarmGA.connection = stdin())
      close(f)
      expect_true(nrow(resultrect) == 1)
      expect_is(resultrect, "matrix")
      expect_false(any(unlist(sapply(resultrect, is.na))))
      plres <- plot_result(resultrect, sp_polygon, topographie = T)
      expect_false(anyNA(plres))
      expect_true(all(plres$EfficAllDir <= 100))
      plres <- plot_result(resultrect, sp_polygon, topographie = T, 
          sourceCCLRoughness = sourceCCLRoughness, weibullsrc = list(k_raster, 
              a_raster))
      expect_false(anyNA(plres))
      expect_true(all(plres$EfficAllDir <= 100))
      plres <- plot_result(resultrect, sp_polygon, topographie = T, 
          plotEn = 2, sourceCCLRoughness = sourceCCLRoughness, 
          weibullsrc = list(k_raster, a_raster))
      expect_false(anyNA(plres))
      expect_true(all(plres$EfficAllDir <= 100))
      plres <- plot_result(resultrect, sp_polygon, topographie = T, 
          plotEn = 2, sourceCCLRoughness = sourceCCLRoughness, 
          weibullsrc = list(a_raster * (gamma(1 + (1/k_raster)))))
      expect_false(anyNA(plres))
      expect_true(all(plres$EfficAllDir <= 100))
      weibullraster <- a_raster * (gamma(1 + (1/k_raster)))
      plres <- plot_result(resultrect, sp_polygon, topographie = T, 
          plotEn = 2, sourceCCLRoughness = sourceCCLRoughness, 
          weibullsrc = weibullraster)
      expect_false(anyNA(plres))
      expect_true(all(plres$EfficAllDir <= 100))
      plres <- plot_result(resultrect, sp_polygon, topographie = T, 
          plotEn = 2)
      expect_false(anyNA(plres))
      expect_true(all(plres$EfficAllDir <= 100))
      if (length(list.files(pattern = "g100_06.tif")) != 0) {
          file.remove("g100_06.tif")
      }
      plres <- plot_result(resultrect, sp_polygon, topographie = T, 
          plotEn = 1)
      expect_false(anyNA(plres))
      expect_true(all(plres$EfficAllDir <= 100))
      if (length(list.files(pattern = "g100_06.tif")) != 0) {
          file.remove("g100_06.tif")
      }
      plres <- plot_result(resultrect, sp_polygon, topographie = T, 
          plotEn = 2)
      expect_false(anyNA(plres))
      expect_true(all(plres$EfficAllDir <= 100))
      Polygon1 <- Polygon(rbind(c(4488182, 2667172), c(4488182, 
          2669343), c(4499991, 2669343), c(4499991, 2667172)))
      Polygon1 <- Polygons(list(Polygon1), 1)
      Polygon1 <- SpatialPolygons(list(Polygon1))
      Projection <- "+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000\n  +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
      proj4string(Polygon1) <- CRS(Projection)
      srtm <- getDEM(Polygon1)
      srtm_crop <- raster::crop(srtm[[1]], Polygon1)
      data.in <- data.frame(ws = 12, wd = 0)
      Rotor <- 50
      fcrR <- 3
      resGrid <- GridFilter(shape = Polygon1, resol = Rotor * 5, 
          prop = 1, plotGrid = FALSE)
      resStartGA <- StartGA(Grid = resGrid[[1]], n = 15, nStart = 100)
      srtm_crop <- raster::mask(srtm_crop, Polygon1)
      roughrast <- raster::terrain(srtm_crop, "roughness")
      if (all(is.na(values(roughrast)))) {
          values(roughrast) <- 1
      }
      srtm_crop <- list(strm_crop = srtm_crop, orogr1 = raster::calc(srtm_crop, 
          function(x) {
              x/(raster::cellStats(srtm_crop, mean, na.rm = TRUE))
          }), roughness = roughrast)
      ccl <- raster::raster("g100_06.tif")
      ccl <- crop(ccl, Polygon1)
      ccl <- mask(ccl, Polygon1)
      path <- paste0(system.file(package = "windfarmGA"), "/extdata/")
      sourceCCLRoughness <- paste0(path, "clc_legend.csv")
      rauhigkeitz <- utils::read.csv(sourceCCLRoughness, header = TRUE, 
          sep = ";")
      cclRaster <- raster::reclassify(ccl, matrix(c(rauhigkeitz$GRID_CODE, 
          rauhigkeitz$Rauhigkeit_z), ncol = 2))
      resCalcEn <- calculate_energy(sel = resStartGA[[1]], referenceHeight = 50, 
          srtm_crop = srtm_crop, cclRaster = cclRaster, RotorHeight = 50, 
          SurfaceRoughness = 0.14, wnkl = 20, distanz = 1e+05, 
          resol = 200, dirSpeed = data.in, RotorR = 50, polygon1 = Polygon1, 
          topograp = TRUE, weibull = FALSE, plotit = T)
      expect_output(str(resCalcEn), "List of 1")
      expect_true(class(resCalcEn[[1]]) == "matrix")
      df <- do.call(rbind, resCalcEn)
      expect_true(all(df[df[, "A_ov"] != 0, "TotAbschProz"] != 
          0))
      expect_true(all(df[df[, "TotAbschProz"] != 0, "V_New"] < 
          df[df[, "TotAbschProz"] != 0, "Windmean"]))
      expect_false(any(unlist(sapply(resCalcEn, is.na))))
      expect_true(all(df[, "Rect_ID"] %in% resGrid[[1]][, "ID"]))
      DEM <- raster("srtm_39_03.tif")
      Polygon1 <- spTransform(Polygon1, CRS(proj4string(DEM)))
      DEMcrop <- crop(DEM, Polygon1)
      maxval <- max(values(DEMcrop))
      a_raster <- raster::calc(DEMcrop, function(x) (x/maxval) + 
          1)
      k_raster <- raster::calc(DEMcrop, function(x) (x/maxval) + 
          6)
      weibullraster <- a_raster * (gamma(1 + (1/k_raster)))
      weibullraster <- projectRaster(weibullraster, crs = CRS(Projection))
      Polygon1 <- spTransform(Polygon1, CRS(Projection))
      resCalcEn <- calculate_energy(sel = resStartGA[[1]], referenceHeight = 50, 
          srtm_crop = srtm_crop, cclRaster = cclRaster, RotorHeight = 50, 
          SurfaceRoughness = 0.14, wnkl = 20, distanz = 1e+05, 
          resol = 200, dirSpeed = data.in, RotorR = 50, polygon1 = Polygon1, 
          topograp = FALSE, weibull = weibullraster, plotit = T)
      expect_output(str(resCalcEn), "List of 1")
      expect_true(class(resCalcEn[[1]]) == "matrix")
      df <- do.call(rbind, resCalcEn)
      expect_true(all(df[df[, "A_ov"] != 0, "TotAbschProz"] != 
          0))
      expect_true(all(df[df[, "TotAbschProz"] != 0, "V_New"] < 
          df[df[, "TotAbschProz"] != 0, "Windmean"]))
      expect_false(any(unlist(sapply(resCalcEn, is.na))))
      expect_true(all(df[, "Rect_ID"] %in% resGrid[[1]][, "ID"]))
      weibullraster <- projectRaster(weibullraster, crs = CRS(Projection))
      Polygon1 <- spTransform(Polygon1, CRS(Projection))
      min_y_ppt <- data.frame(resStartGA[[1]][order(resStartGA[[1]][, 
          2]) <= 9, ])
      coordinates(min_y_ppt) <- ~X + Y
      weibullrastercrop <- crop(weibullraster, extent(min_y_ppt))
      resCalcEn <- calculate_energy(sel = resStartGA[[1]], referenceHeight = 50, 
          srtm_crop = srtm_crop, cclRaster = cclRaster, RotorHeight = 50, 
          SurfaceRoughness = 0.14, wnkl = 20, distanz = 1e+05, 
          resol = 200, dirSpeed = data.in, RotorR = 50, polygon1 = Polygon1, 
          topograp = FALSE, weibull = weibullrastercrop, plotit = T)
      expect_output(str(resCalcEn), "List of 1")
      expect_true(class(resCalcEn[[1]]) == "matrix")
      df <- do.call(rbind, resCalcEn)
      expect_true(all(df[df[, "A_ov"] != 0, "TotAbschProz"] != 
          0))
      expect_true(all(df[df[, "TotAbschProz"] != 0, "V_New"] < 
          df[df[, "TotAbschProz"] != 0, "Windmean"]))
      expect_false(any(unlist(sapply(resCalcEn, is.na))))
      expect_true(all(df[, "Rect_ID"] %in% resGrid[[1]][, "ID"]))
  })
  where 18: eval(code, test_env)
  where 19: eval(code, test_env)
  where 20: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 21: doTryCatch(return(expr), name, parentenv, handler)
  where 22: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 23: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 24: doTryCatch(return(expr), name, parentenv, handler)
  where 25: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 26: tryCatchList(expr, classes, parentenv, handlers)
  where 27: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 28: test_code(NULL, exprs, env)
  where 29: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 30: force(code)
  where 31: doWithOneRestart(return(expr), restart)
  where 32: withOneRestart(expr, restarts[[1L]])
  where 33: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 34: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter, 
      {
          reporter$start_file(basename(path))
          lister$start_file(basename(path))
          source_file(path, new.env(parent = env), chdir = TRUE, 
              wrap = wrap)
          reporter$.end_context()
          reporter$end_file()
      })
  where 35: FUN(X[[i]], ...)
  where 36: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 37: force(code)
  where 38: doWithOneRestart(return(expr), restart)
  where 39: withOneRestart(expr, restarts[[1L]])
  where 40: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 41: with_reporter(reporter = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 42: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 43: test_dir(path = test_path, reporter = reporter, env = env, filter = filter, 
      ..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning, 
      wrap = wrap)
  where 44: test_package_dir(package = package, test_path = test_path, filter = filter, 
      reporter = reporter, ..., stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 45: test_check("windfarmGA")
  
   --- value of length: 2 type: logical ---
  [1] TRUE TRUE
   --- function from context --- 
  function (data, height, po = 101325, ro = 1.225) 
  {
      if (is.numeric(data) || (ncol(data)) == 1) {
          ph <- as.numeric(po * exp(-data * 0.0001252))
          rh <- as.numeric(ro * exp(-data * 0.0001252))
          Th <- as.numeric(288.15 - ((6.5 * data)/1000))
      }
      else {
          if (missing(height)) {
              stop("Height column not given.")
          }
          data <- data[, height]
          ph <- po * exp(-data * 0.0001252)
          rh <- ro * exp(-data * 0.0001252)
          Th <- 288.15 - ((6.5 * data)/1000)
      }
      if (class(data) != "data.frame") {
          data <- data.frame(data)
      }
      colnames(data) <- "Height"
      celsius <- as.numeric(Th - 273.15)
      data$ph <- ph
      data$rh <- rh
      data$tempK <- Th
      data$tempC <- celsius
      return(data)
  }
  <bytecode: 0xd4d0f60>
  <environment: namespace:windfarmGA>
   --- function search by body ---
  Function barometric_height in namespace windfarmGA has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 4. Error: Test Terrain and Weibull Effects (@test_terrain.R#39)  ------------
  the condition has length > 1
  Backtrace:
   1. windfarmGA::genAlgo(...)
   2. windfarmGA::genetic_algorithm(...)
   3. windfarmGA::fitness(...)
   4. windfarmGA::calculate_energy(...)
   5. windfarmGA::barometric_height(matrix(turb_elev), turb_elev)
  
   [1] "ABBREV"       "ADM0_A3"      "ADM0_DIF"     "ADMIN"        "ADMIN.1"     
   [6] "AVOIDname"    "AVOIDnumeric" "FIPS_10_"     "FeatureCla"   "GBD"         
  [11] "GDP_MD_EST"   "GEO3"         "GEO3major"    "GEOUNIT"      "GEOU_DIF"    
  [16] "GLOCAF"       "GU_A3"        "IMAGE24"      "ISO3"         "ISO3.1"      
  [21] "ISO_A2"       "ISO_A3"       "ISO_N3"       "LAT"          "LDC"         
  [26] "LEVEL"        "LLDC"         "LON"          "LabelRank"    "MAP_COLOR"   
  [31] "NAME"         "NAME_FORMA"   "NAME_SORT"    "POP_EST"      "POSTAL"      
  [36] "REGION"       "SID"          "SOVEREIGNT"   "SOV_A3"       "SRES"        
  [41] "SRESmajor"    "SUBUNIT"      "SU_A3"        "SU_DIF"       "ScaleRank"   
  [46] "Stern"        "TERR_"        "TYPE"         "continent"   
  Enter an ISO3 code:  [1] "ABBREV"       "ADM0_A3"      "ADM0_DIF"     "ADMIN"        "ADMIN.1"     
   [6] "AVOIDname"    "AVOIDnumeric" "FIPS_10_"     "FeatureCla"   "GBD"         
  [11] "GDP_MD_EST"   "GEO3"         "GEO3major"    "GEOUNIT"      "GEOU_DIF"    
  [16] "GLOCAF"       "GU_A3"        "IMAGE24"      "ISO3"         "ISO3.1"      
  [21] "ISO_A2"       "ISO_A3"       "ISO_N3"       "LAT"          "LDC"         
  [26] "LEVEL"        "LLDC"         "LON"          "LabelRank"    "MAP_COLOR"   
  [31] "NAME"         "NAME_FORMA"   "NAME_SORT"    "POP_EST"      "POSTAL"      
  [36] "REGION"       "SID"          "SOVEREIGNT"   "SOV_A3"       "SRES"        
  [41] "SRESmajor"    "SUBUNIT"      "SU_A3"        "SU_DIF"       "ScaleRank"   
  [46] "Stern"        "TERR_"        "TYPE"         "continent"   
  Enter an ISO3 code: Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  Enter the turbine number that you want to optimize.Please enter the corresponding number:
  
  Hit <ENTER> if this is your Polygon
  No Projection is given. Take Lambert Azimuthal Equal Area Projection.
  
  Hit <ENTER> if this is your Polygon
  
  Select appropriate Method. Either 'EQU' for equal crossover parts or 'RAN' for random parts.
  Type 'R' for random and 'E' for equal parts.
  
  Select appropriate Method. Either 'EQU' for equal crossover parts or 'RAN' for random parts.
  Type 'R' for random and 'E' for equal parts.
  
  Select appropriate Selection Method. Either 'FIX' or 'VAR' are available.
  Type 'F' for a fixed percentage of 50% and 'V' for a variable percentage.
  
  Press <ENTER> if the windrose looks correct?
  
  Is the grid spacing appropriate?Type 'ENTER' if the the grid is corrent and 'n' if you like to change some inputs.################### GA WARNING MESSAGE ###################
  Hit <ENTER> if this is your Polygon
  No Projection is given. Take Lambert Azimuthal Equal Area Projection.
  
  Hit <ENTER> if this is your Polygon
  
  Select appropriate Method. Either 'EQU' for equal crossover parts or 'RAN' for random parts.
  Type 'R' for random and 'E' for equal parts.
  
  Select appropriate Method. Either 'EQU' for equal crossover parts or 'RAN' for random parts.
  Type 'R' for random and 'E' for equal parts.
  
  Select appropriate Selection Method. Either 'FIX' or 'VAR' are available.
  Type 'F' for a fixed percentage of 50% and 'V' for a variable percentage.
  
  Press <ENTER> if the windrose looks correct?
  
  Is the grid spacing appropriate?Type 'ENTER' if the the grid is corrent and 'n' if you like to change some inputs....trying URL 'https://biogeo.ucdavis.edu/data/diva/msk_alt/AUT_msk_alt.zip'
  Content type 'application/zip' length 216165 bytes (211 KB)
  ==================================================
  downloaded 211 KB
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  windfarmGA
   --- call from context --- 
  viewshed(r = DEM_meter[[1]], shape = sf_shape, turbine_locs = turblocdf, 
      h1 = 1.8, h2 = 50)
   --- call from argument --- 
  if (class(turbine_locs) == "SpatialPoints") {
      turbine_locs <- sp::coordinates(turbine_locs)
  }
   --- R stacktrace ---
  where 1 at testthat/test_visibility.R#70: viewshed(r = DEM_meter[[1]], shape = sf_shape, turbine_locs = turblocdf, 
      h1 = 1.8, h2 = 50)
  where 2: eval(code, test_env)
  where 3: eval(code, test_env)
  where 4: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 5: doTryCatch(return(expr), name, parentenv, handler)
  where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 8: doTryCatch(return(expr), name, parentenv, handler)
  where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 10: tryCatchList(expr, classes, parentenv, handlers)
  where 11: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 12: test_code(desc, code, env = parent.frame())
  where 13 at testthat/test_visibility.R#8: test_that("Test Viewshed Functions", {
      Polygon1 <- Polygon(rbind(c(4488182, 2667172), c(4488182, 
          2669343), c(4499991, 2669343), c(4499991, 2667172)))
      Polygon1 <- Polygons(list(Polygon1), 1)
      Polygon1 <- SpatialPolygons(list(Polygon1))
      Projection <- "+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000\n  +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
      proj4string(Polygon1) <- CRS(Projection)
      DEM_meter <- getDEM(Polygon1)
      expect_is(DEM_meter, "list")
      expect_true(class(DEM_meter[[1]]) == "RasterLayer")
      expect_true(class(DEM_meter[[2]]) == "SpatialPolygonsDataFrame")
      DEM_noclip <- getDEM(Polygon1, clip = FALSE)
      expect_is(DEM_noclip, "list")
      expect_true(class(DEM_noclip[[1]]) == "RasterLayer")
      expect_true(is.null(DEM_noclip[[2]]))
      points <- cbind(c(4488182.26267016, 4488852.91748256), c(2667398.93118627, 
          2667398.93118627))
      res <- getISO3(pp = points, crs_pp = 3035)
      expect_true(res == "AUT")
      expect_true(nrow(res) == 1)
      expect_true(ncol(res) == 1)
      expect_is(res, "data.frame")
      points <- as.data.frame(points)
      colnames(points) <- c("x", "y")
      points <- st_as_sf(points, coords = c("x", "y"))
      st_crs(points) <- 3035
      ressf <- getISO3(pp = points, crs_pp = 3035)
      expect_true(ressf == "AUT")
      expect_true(nrow(ressf) == 1)
      expect_true(ncol(ressf) == 1)
      expect_is(ressf, "data.frame")
      ressf <- getISO3(pp = points, crs_pp = 3035, col = c("ABBREV", 
          "ADMIN", "LON", "LAT"))
      expect_true("ADMIN" %in% colnames(ressf))
      expect_true(ressf$ADMIN == "Austria")
      expect_true(nrow(ressf) == 1)
      expect_true(ncol(ressf) == 4)
      expect_is(ressf, "data.frame")
      turbloc <- spsample(DEM_meter[[2]], 10, type = "random")
      res <- viewshed(r = DEM_meter[[1]], shape = DEM_meter[[2]], 
          turbine_locs = turbloc, h1 = 1.8, h2 = 50)
      expect_is(res, "list")
      expect_true(length(res) == 5)
      expect_true(is.logical(as.vector(res[[1]])))
      expect_false(anyNA(res[[2]]))
      expect_true(class(res[[3]])[[1]] == "sf")
      expect_true(class(res[[4]]) == "RasterLayer")
      expect_false(anyNA(res[[5]]))
      turblocdf <- sp::coordinates(turbloc)
      sf_shape <- st_as_sf(DEM_meter[[2]])
      res <- viewshed(r = DEM_meter[[1]], shape = sf_shape, turbine_locs = turblocdf, 
          h1 = 1.8, h2 = 50)
      expect_is(res, "list")
      expect_true(length(res) == 5)
      expect_true(is.logical(as.vector(res[[1]])))
      expect_false(anyNA(res[[2]]))
      expect_true(class(res[[3]])[[1]] == "sf")
      expect_true(class(res[[4]]) == "RasterLayer")
      expect_false(anyNA(res[[5]]))
      plt <- plot_viewshed(res)
      expect_true(is.null(plt))
      plt <- plot_viewshed(res, legend = T)
      expect_true(is.null(plt))
      turbloc <- spsample(DEM_meter[[2]], 1, type = "random")
      res <- viewshed(r = DEM_meter[[1]], shape = DEM_meter[[2]], 
          turbine_locs = turbloc, h1 = 1.8, h2 = 50)
      plt <- plot_viewshed(res, legend = T)
      expect_true(is.null(plt))
      sample_POI <- spsample(DEM_meter[[2]], n = ncell(DEM_meter[[1]]), 
          type = "regular")
      sample_xy <- coordinates(sample_POI)
      n <- 10
      saplms <- sample(1:nrow(sample_xy), size = n, F)
      reso = min(res(DEM_meter[[1]]))
      reslist <- list()
      for (i in seq(1, n, 2)) {
          reslist[[i]] <- rasterprofile(r = DEM_meter[[1]], xy1 = sample_xy[i, 
              ], xy2 = sample_xy[i + 1, ], reso, F)
      }
      resdf <- do.call(rbind, reslist[seq(1, n, 2)])
      expect_false(anyNA(resdf))
      expect_true(ncol(resdf) == 3)
      rppl <- rasterprofile(r = DEM_meter[[1]], xy1 = sample_xy[10, 
          ], xy2 = sample_xy[26, ], reso, T)
      expect_false(anyNA(rppl))
      expect_true(ncol(rppl) == 3)
      viwres <- viewTo(DEM_meter[[1]], xy1 = turblocdf[1, ], sample_xy, 
          h1 = 1.5, h2 = 10, reso)
      expect_true(is.logical(viwres))
      canrs <- cansee(DEM_meter[[1]], turblocdf[1, ], sample_xy[3, 
          ], h1 = 0, h2 = 0, reso)
      expect_true(is.logical(canrs))
      expect_true(length(canrs) == 1)
      Polygon1 <- Polygon(rbind(c(4498482, 2668272), c(4498482, 
          2669343), c(4499991, 2669343), c(4499991, 2668272)))
      Polygon1 <- Polygons(list(Polygon1), 1)
      Polygon1 <- SpatialPolygons(list(Polygon1))
      Projection <- "+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000\n+ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
      proj4string(Polygon1) <- CRS(Projection)
      r <- getDEM(polygon = Polygon1, ISO3 = "AUT", clip = T)
      xy1 <- spsample(Polygon1, 1, "random")
      xy1 <- as.vector(coordinates(xy1))
      xy2 <- spsample(Polygon1, 5, "random")
      xy2 <- coordinates(xy2)
      a <- t(apply(xy2, 1, function(d) {
          cansee(r[[1]], xy1 = xy1, xy2 = d, h1 = 0, h2 = 0, reso)
      }))
      expect_true(is.logical(a))
      expect_false(anyNA(a))
      turbloc <- spsample(DEM_meter[[2]], 10, type = "random")
      res <- viewshed(r = DEM_meter[[1]], shape = DEM_meter[[2]], 
          turbine_locs = turbloc, h1 = 1.8, h2 = 50)
      resinpl <- interpol_view(res, plotDEM = T, alpha = 0.5)
      expect_is(resinpl, "RasterLayer")
      resinpl <- interpol_view(res, plotDEM = T, alpha = 0.5, breakseq = seq(0, 
          10, 1), colNA = "black")
      expect_is(resinpl, "RasterLayer")
      resinpl <- interpol_view(res, alpha = 1, breakseq = seq(1, 
          10, 2))
      expect_is(resinpl, "RasterLayer")
      resinpl <- interpol_view(res, alpha = 1, breakseq = seq(1, 
          4, 2))
      expect_is(resinpl, "RasterLayer")
      resinpl <- interpol_view(res, alpha = 1.2, breakform = quantile)
      expect_is(resinpl, "RasterLayer")
      resinpl <- interpol_view(res, alpha = 1, breakform = factor)
      expect_is(resinpl, "RasterLayer")
  })
  where 14: eval(code, test_env)
  where 15: eval(code, test_env)
  where 16: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 17: doTryCatch(return(expr), name, parentenv, handler)
  where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 20: doTryCatch(return(expr), name, parentenv, handler)
  where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 22: tryCatchList(expr, classes, parentenv, handlers)
  where 23: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 24: test_code(NULL, exprs, env)
  where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 26: force(code)
  where 27: doWithOneRestart(return(expr), restart)
  where 28: withOneRestart(expr, restarts[[1L]])
  where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter, 
      {
          reporter$start_file(basename(path))
          lister$start_file(basename(path))
          source_file(path, new.env(parent = env), chdir = TRUE, 
              wrap = wrap)
          reporter$.end_context()
          reporter$end_file()
      })
  where 31: FUN(X[[i]], ...)
  where 32: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 33: force(code)
  where 34: doWithOneRestart(return(expr), restart)
  where 35: withOneRestart(expr, restarts[[1L]])
  where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 37: with_reporter(reporter = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter, 
      ..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning, 
      wrap = wrap)
  where 40: test_package_dir(package = package, test_path = test_path, filter = filter, 
      reporter = reporter, ..., stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 41: test_check("windfarmGA")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (r, shape, turbine_locs, h1 = 0, h2 = 0) 
  {
      if (class(shape)[1] == "sf") {
          shape <- as(shape, "Spatial")
      }
      if (class(turbine_locs) == "SpatialPoints") {
          turbine_locs <- sp::coordinates(turbine_locs)
      }
      mw <- methods::as(r, "SpatialPixelsDataFrame")
      mw <- methods::as(mw, "SpatialPolygons")
      sample_xy <- sp::coordinates(mw)
      rownames(sample_xy) <- NULL
      colnames(sample_xy) <- c("x1", "x2")
      reso <- min(raster::res(r))
      res <- t(apply(turbine_locs, 1, function(d) {
          viewTo(r, xy1 = d, xy2 = sample_xy, h1, h2, reso)
      }))
      return(list(Result = res, Raster_POI = sample_xy, Area = sf::st_as_sf(shape), 
          DEM = r, Turbines = turbine_locs))
  }
  <bytecode: 0xd873078>
  <environment: namespace:windfarmGA>
   --- function search by body ---
  Function viewshed in namespace windfarmGA has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 5. Error: Test Viewshed Functions (@test_visibility.R#70)  ------------------
  the condition has length > 1
  Backtrace:
   1. windfarmGA::viewshed(...)
  
  -- 6. Failure: Test Wake Functions (@test_wake.R#194)  -------------------------
  all(sapply(resStartGA, class) == "matrix") isn't true.
  
  -- 7. Failure: Test Wake Functions (@test_wake.R#209)  -------------------------
  class(resCalcEn[[1]]) == "matrix" isn't true.
  
  -- 8. Failure: Test Wake Functions (@test_wake.R#225)  -------------------------
  class(resCalcEn[[1]]) == "matrix" isn't true.
  
  -- 9. Failure: Test Wake Functions (@test_wake.R#237)  -------------------------
  class(resCalcEn[[1]]) == "matrix" isn't true.
  
  
  Hit <ENTER> if this is your Polygon
  No Projection is given. Take Lambert Azimuthal Equal Area Projection.
  
  Hit <ENTER> if this is your Polygon
  
  Press <ENTER> if the windrose looks correct?
  
  Is the grid spacing appropriate?Type 'ENTER' if the the grid is corrent and 'n' if you like to change some inputs......OGR data source with driver: ESRI Shapefile 
  Source: "/home/hornik/tmp/R.check/r-devel-clang/Work/build/Packages/windfarmGA/extdata/shape.shp", layer: "shape"
  with 1 features
  It has 1 fields
  
  Hit <ENTER> if this is your Polygon
  No Projection is given. Take Lambert Azimuthal Equal Area Projection.
  
  Hit <ENTER> if this is your Polygon
  
  Press <ENTER> if the windrose looks correct?
  
  Is the grid spacing appropriate?Type 'ENTER' if the the grid is corrent and 'n' if you like to change some inputs....
  Hit <ENTER> if this is your Polygon
  Polygon is not projected. Lambert Azimuthal Equal Area Projection is used.
  
  Hit <ENTER> if this is your Polygon
  
  Press <ENTER> if the windrose looks correct?
  
  Is the grid spacing appropriate?Type 'ENTER' if the the grid is corrent and 'n' if you like to change some inputs......
  Hit <ENTER> if this is your Polygon
  Polygon is not projected. Lambert Azimuthal Equal Area Projection is used.
  
  Hit <ENTER> if this is your Polygon
  
  Press <ENTER> if the windrose looks correct?
  
  Is the grid spacing appropriate?Type 'ENTER' if the the grid is corrent and 'n' if you like to change some inputs......
  Hit <ENTER> if this is your Polygon
  Polygon is not projected. Lambert Azimuthal Equal Area Projection is used.
  
  Hit <ENTER> if this is your Polygon
  
  Hit <ENTER> if this is your Polygon
  Polygon is not projected. Lambert Azimuthal Equal Area Projection is used.
  
  Hit <ENTER> if this is your Polygon
  
  Press <ENTER> if the windrose looks correct?
  ################### GA WARNING MESSAGE ###################
  Hit <ENTER> if this is your Polygon
  Polygon is not projected. Lambert Azimuthal Equal Area Projection is used.
  
  Hit <ENTER> if this is your Polygon
  
  Press <ENTER> if the windrose looks correct?
  ################### GA WARNING MESSAGE ###################
  Hit <ENTER> if this is your Polygon
  Polygon is not projected. Lambert Azimuthal Equal Area Projection is used.
  
  Hit <ENTER> if this is your Polygon
  
  Press <ENTER> if the windrose looks correct?
  
  Is the grid spacing appropriate?Type 'ENTER' if the the grid is corrent and 'n' if you like to change some inputs.weibullsrc class: 
  1 -  data.frame
  Hit <ENTER> if this is your Polygon
  Polygon is not projected. Lambert Azimuthal Equal Area Projection is used.
  
  Hit <ENTER> if this is your Polygon
  
  Press <ENTER> if the windrose looks correct?
  
  Is the grid spacing appropriate?Type 'ENTER' if the the grid is corrent and 'n' if you like to change some inputs.list item classes: 
  1 -  numeric 
  2 -  numeric== testthat results  ===========================================================
  [ OK: 527 | SKIPPED: 2 | WARNINGS: 106 | FAILED: 9 ]
  1. Error: Test Genetic Algorithm Function (@test_ga_func.R#31) 
  2. Failure: Test Plotting Functions (@test_plots.R#167) 
  3. Failure: Test Plotting Functions (@test_plots.R#172) 
  4. Error: Test Terrain and Weibull Effects (@test_terrain.R#39) 
  5. Error: Test Viewshed Functions (@test_visibility.R#70) 
  6. Failure: Test Wake Functions (@test_wake.R#194) 
  7. Failure: Test Wake Functions (@test_wake.R#209) 
  8. Failure: Test Wake Functions (@test_wake.R#225) 
  9. Failure: Test Wake Functions (@test_wake.R#237) 
  
  Error: testthat unit tests failed
  Execution halted