Running 'testthat.R' [107s/117s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
  > library(testthat)
  > library(landscapemetrics)
  > library(raster)
  Loading required package: sp
  > 
  > test_check("landscapemetrics")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L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, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L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, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, what = "patch", verbose = FALSE)
  where 13 at testthat/test-calculate-lsm.R#5: calculate_lsm(landscape, what = "patch", verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 25 at testthat/test-calculate-lsm.R#3: test_that("calculate_lsm can calculate patch metrics", {
      patch_metrics <- calculate_lsm(landscape, what = "patch", 
          verbose = FALSE)
      expect_is(patch_metrics, "tbl_df")
      expect_true(all(patch_metrics$level == "patch"))
      expect_true(ncol(patch_metrics) > 0)
  })
  where 26: eval(code, test_env)
  where 27: eval(code, test_env)
  where 28: 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 29: doTryCatch(return(expr), name, parentenv, handler)
  where 30: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 31: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 32: doTryCatch(return(expr), name, parentenv, handler)
  where 33: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 34: tryCatchList(expr, classes, parentenv, handlers)
  where 35: 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 36: test_code(NULL, exprs, env)
  where 37: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 38: force(code)
  where 39: doWithOneRestart(return(expr), restart)
  where 40: withOneRestart(expr, restarts[[1L]])
  where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 42: 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 43: FUN(X[[i]], ...)
  where 44: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 45: force(code)
  where 46: doWithOneRestart(return(expr), restart)
  where 47: withOneRestart(expr, restarts[[1L]])
  where 48: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 49: 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 50: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 51: 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 52: 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 53: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 1. Error: calculate_lsm can calculate patch metrics (@test-calculate-lsm.R#5)
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::calculate_lsm(landscape, what = "patch", verbose = FALSE)
    2. landscapemetrics:::calculate_lsm.RasterLayer(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. base::lapply(...)
    7. landscapemetrics:::FUN(X[[i]], ...)
    8. base::tryCatch(...)
    9. base:::tryCatchList(expr, classes, parentenv, handlers)
   10. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   11. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      like_adjacencies <- rcpp_get_coocurrence_matrix_diag(landscape, 
          directions = as.matrix(4))/2
      cells_class <- rcpp_get_composition_vector(landscape)
      cells_class <- tibble::tibble(class = names(cells_class), 
          value = cells_class)
      cells_class$n <- trunc(sqrt(cells_class$value))
      cells_class$m <- cells_class$value - cells_class$n^2
      cells_class$max_adj <- ifelse(test = cells_class$m == 0, 
          yes = 2 * cells_class$n * (cells_class$n - 1), no = ifelse(test = cells_class$m <= 
              cells_class$n, yes = 2 * cells_class$n * (cells_class$n - 
              1) + 2 * cells_class$m - 1, no = ifelse(test = cells_class$m > 
              cells_class$n, yes = 2 * cells_class$n * (cells_class$n - 
              1) + 2 * cells_class$m - 2, no = NA)))
      if (anyNA(cells_class$max_adj)) {
          warning("NAs introduced by lsm_c_ai", call. = FALSE)
      }
      max_adj <- cells_class$max_adj
      ai <- (like_adjacencies/max_adj) * 100
      ai[is.nan(ai)] <- NA
      tibble::tibble(level = "class", class = as.integer(names(like_adjacencies)), 
          id = as.integer(NA), metric = "ai", value = as.double(ai))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 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, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      like_adjacencies <- rcpp_get_coocurrence_matrix_diag(landscape, 
          directions = as.matrix(4))/2
      cells_class <- rcpp_get_composition_vector(landscape)
      cells_class <- tibble::tibble(class = names(cells_class), 
          value = cells_class)
      cells_class$n <- trunc(sqrt(cells_class$value))
      cells_class$m <- cells_class$value - cells_class$n^2
      cells_class$max_adj <- ifelse(test = cells_class$m == 0, 
          yes = 2 * cells_class$n * (cells_class$n - 1), no = ifelse(test = cells_class$m <= 
              cells_class$n, yes = 2 * cells_class$n * (cells_class$n - 
              1) + 2 * cells_class$m - 1, no = ifelse(test = cells_class$m > 
              cells_class$n, yes = 2 * cells_class$n * (cells_class$n - 
              1) + 2 * cells_class$m - 2, no = NA)))
      if (anyNA(cells_class$max_adj)) {
          warning("NAs introduced by lsm_c_ai", call. = FALSE)
      }
      max_adj <- cells_class$max_adj
      ai <- (like_adjacencies/max_adj) * 100
      ai[is.nan(ai)] <- NA
      tibble::tibble(level = "class", class = as.integer(names(like_adjacencies)), 
          id = as.integer(NA), metric = "ai", value = as.double(ai))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,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L, 3L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, what = "class", verbose = FALSE)
  where 13 at testthat/test-calculate-lsm.R#15: calculate_lsm(landscape, what = "class", verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 25 at testthat/test-calculate-lsm.R#13: test_that("calculate_lsm can calculate class metrics", {
      class_metrics <- calculate_lsm(landscape, what = "class", 
          verbose = FALSE)
      expect_is(class_metrics, "tbl_df")
      expect_true(all(class_metrics$level == "class"))
      expect_true(ncol(class_metrics) > 0)
  })
  where 26: eval(code, test_env)
  where 27: eval(code, test_env)
  where 28: 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 29: doTryCatch(return(expr), name, parentenv, handler)
  where 30: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 31: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 32: doTryCatch(return(expr), name, parentenv, handler)
  where 33: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 34: tryCatchList(expr, classes, parentenv, handlers)
  where 35: 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 36: test_code(NULL, exprs, env)
  where 37: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 38: force(code)
  where 39: doWithOneRestart(return(expr), restart)
  where 40: withOneRestart(expr, restarts[[1L]])
  where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 42: 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 43: FUN(X[[i]], ...)
  where 44: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 45: force(code)
  where 46: doWithOneRestart(return(expr), restart)
  where 47: withOneRestart(expr, restarts[[1L]])
  where 48: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 49: 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 50: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 51: 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 52: 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 53: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      like_adjacencies <- rcpp_get_coocurrence_matrix_diag(landscape, 
          directions = as.matrix(4))/2
      cells_class <- rcpp_get_composition_vector(landscape)
      cells_class <- tibble::tibble(class = names(cells_class), 
          value = cells_class)
      cells_class$n <- trunc(sqrt(cells_class$value))
      cells_class$m <- cells_class$value - cells_class$n^2
      cells_class$max_adj <- ifelse(test = cells_class$m == 0, 
          yes = 2 * cells_class$n * (cells_class$n - 1), no = ifelse(test = cells_class$m <= 
              cells_class$n, yes = 2 * cells_class$n * (cells_class$n - 
              1) + 2 * cells_class$m - 1, no = ifelse(test = cells_class$m > 
              cells_class$n, yes = 2 * cells_class$n * (cells_class$n - 
              1) + 2 * cells_class$m - 2, no = NA)))
      if (anyNA(cells_class$max_adj)) {
          warning("NAs introduced by lsm_c_ai", call. = FALSE)
      }
      max_adj <- cells_class$max_adj
      ai <- (like_adjacencies/max_adj) * 100
      ai[is.nan(ai)] <- NA
      tibble::tibble(level = "class", class = as.integer(names(like_adjacencies)), 
          id = as.integer(NA), metric = "ai", value = as.double(ai))
  }
  <bytecode: 0x82d9980>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_c_ai_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 2. Error: calculate_lsm can calculate class metrics (@test-calculate-lsm.R#15
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::calculate_lsm(landscape, what = "class", verbose = FALSE)
    2. landscapemetrics:::calculate_lsm.RasterLayer(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. base::lapply(...)
    7. landscapemetrics:::FUN(X[[i]], ...)
    8. base::tryCatch(...)
    9. base:::tryCatchList(expr, classes, parentenv, handlers)
   10. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   11. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      ai <- lsm_c_ai_calc(landscape)
      pland <- lsm_c_pland_calc(landscape, directions = 8, resolution = resolution)
      result <- sum(ai$value * (pland$value/100))
      tibble::tibble(level = "landscape", class = as.integer(NA), 
          id = as.integer(NA), metric = "ai", value = as.double(result))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L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, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), resolution = c(1, 1))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      ai <- lsm_c_ai_calc(landscape)
      pland <- lsm_c_pland_calc(landscape, directions = 8, resolution = resolution)
      result <- sum(ai$value * (pland$value/100))
      tibble::tibble(level = "landscape", class = as.integer(NA), 
          id = as.integer(NA), metric = "ai", value = as.double(result))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 
  1L, 2L, 3L, 3L, 3L, 3L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, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), resolution = c(1, 1))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, what = "landscape", verbose = FALSE)
  where 13 at testthat/test-calculate-lsm.R#25: calculate_lsm(landscape, what = "landscape", verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 25 at testthat/test-calculate-lsm.R#23: test_that("calculate_lsm can calculate landscape metrics", {
      landscape_metrics <- calculate_lsm(landscape, what = "landscape", 
          verbose = FALSE)
      expect_is(landscape_metrics, "tbl_df")
      expect_true(all(landscape_metrics$level == "landscape"))
      expect_true(ncol(landscape_metrics) > 0)
  })
  where 26: eval(code, test_env)
  where 27: eval(code, test_env)
  where 28: 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 29: doTryCatch(return(expr), name, parentenv, handler)
  where 30: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 31: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 32: doTryCatch(return(expr), name, parentenv, handler)
  where 33: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 34: tryCatchList(expr, classes, parentenv, handlers)
  where 35: 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 36: test_code(NULL, exprs, env)
  where 37: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 38: force(code)
  where 39: doWithOneRestart(return(expr), restart)
  where 40: withOneRestart(expr, restarts[[1L]])
  where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 42: 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 43: FUN(X[[i]], ...)
  where 44: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 45: force(code)
  where 46: doWithOneRestart(return(expr), restart)
  where 47: withOneRestart(expr, restarts[[1L]])
  where 48: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 49: 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 50: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 51: 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 52: 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 53: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      ai <- lsm_c_ai_calc(landscape)
      pland <- lsm_c_pland_calc(landscape, directions = 8, resolution = resolution)
      result <- sum(ai$value * (pland$value/100))
      tibble::tibble(level = "landscape", class = as.integer(NA), 
          id = as.integer(NA), metric = "ai", value = as.double(result))
  }
  <bytecode: 0x815f6e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_l_ai_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 3. Error: calculate_lsm can calculate landscape metrics (@test-calculate-lsm.
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::calculate_lsm(...)
    2. landscapemetrics:::calculate_lsm.RasterLayer(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. base::lapply(...)
    7. landscapemetrics:::FUN(X[[i]], ...)
    8. base::tryCatch(...)
    9. base:::tryCatchList(expr, classes, parentenv, handlers)
   10. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   11. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 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, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 1L, 1L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 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2L, 
  2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 1L, 1L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, verbose = FALSE)
  where 13 at testthat/test-calculate-lsm.R#35: calculate_lsm(landscape, verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 25 at testthat/test-calculate-lsm.R#33: test_that("calculate_lsm can take all metrics", {
      all_metrics <- calculate_lsm(landscape, verbose = FALSE)
      expect_true(all(all_metrics$level %in% c("patch", "class", 
          "landscape")))
      expect_is(all_metrics, "tbl_df")
      expect_true(ncol(all_metrics) > 0)
  })
  where 26: eval(code, test_env)
  where 27: eval(code, test_env)
  where 28: 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 29: doTryCatch(return(expr), name, parentenv, handler)
  where 30: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 31: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 32: doTryCatch(return(expr), name, parentenv, handler)
  where 33: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 34: tryCatchList(expr, classes, parentenv, handlers)
  where 35: 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 36: test_code(NULL, exprs, env)
  where 37: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 38: force(code)
  where 39: doWithOneRestart(return(expr), restart)
  where 40: withOneRestart(expr, restarts[[1L]])
  where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 42: 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 43: FUN(X[[i]], ...)
  where 44: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 45: force(code)
  where 46: doWithOneRestart(return(expr), restart)
  where 47: withOneRestart(expr, restarts[[1L]])
  where 48: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 49: 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 50: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 51: 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 52: 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 53: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 4. Error: calculate_lsm can take all metrics (@test-calculate-lsm.R#35)  ----
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::calculate_lsm(landscape, verbose = FALSE)
    2. landscapemetrics:::calculate_lsm.RasterLayer(landscape, verbose = FALSE)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. base::lapply(...)
    7. landscapemetrics:::FUN(X[[i]], ...)
    8. base::tryCatch(...)
    9. base:::tryCatchList(expr, classes, parentenv, handlers)
   10. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   11. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, verbose, points = NULL) 
  {
      if (class(landscape) != "matrix") {
          points <- raster_to_points(landscape)[, 2:4]
          landscape <- raster::as.matrix(landscape)
      }
      classes <- get_unique_values(landscape)[[1]]
      enn_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          np_class <- max(landscape_labeled, na.rm = TRUE)
          if (np_class == 1) {
              enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
              if (verbose) {
                  warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                    call. = FALSE)
              }
          }
          else {
              class_boundaries <- get_boundaries(landscape_labeled, 
                  directions = 4, as_NA = TRUE)[[1]]
              class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
              class_boundaries <- t(class_boundaries)
              points <- points[which(!is.na(class_boundaries)), 
                  ]
              points[, 3] <- class_boundaries[!is.na(class_boundaries)]
              ord <- order(as.matrix(points)[, 1])
              num <- seq_along(ord)
              rank <- match(num, ord)
              res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
                  ])
              min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
                  3]))
              tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
                  2], id = min_dist[, 3])
              enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 
                  3], FUN = min)
          }
          tibble::tibble(class = patches_class, value = enn$dist)
      }))
      tibble::tibble(level = "patch", class = as.integer(enn_patch$class), 
          id = as.integer(seq_len(nrow(enn_patch))), metric = "enn", 
          value = as.double(enn_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 
  1L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 
  2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 3L, 3L, 
  3L, 2L, 3L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L,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5, 19.5, 20.5, 21.5, 
      22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 
      2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 
      13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 
      23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 
      3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 
      14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 
      24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 
      5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 
      16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 
      26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 
      7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 
      17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 
      27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 
      8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 
      18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 
      28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 
      9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 
      19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 
      29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 
      11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 
      21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 
      1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 
      12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 
      22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 
      2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 
      13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 
      23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 
      3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 
      14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 
      24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 
      5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 
      16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 
      26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 
      7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 
      17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 
      27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 
      8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 
      18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 
      28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 
      9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 
      19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 
      29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 
      11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 
      21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 
      1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 
      12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 
      22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 
      2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 
      13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 
      23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 
      3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 
      14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 
      24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 
      5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 
      16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 
      26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 
      7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 
      17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 
      27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 
      8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 
      18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 
      28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 
      9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 
      19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 
      29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 
      11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 
      21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 
      1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 
      12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 
      22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 
      2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 
      13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 
      23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 
      3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 
      14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 
      24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 
      5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 
      16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 
      26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 
      7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 
      17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 
      27.5, 28.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 
      29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 
      29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 
      29.5, 29.5, 29.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 
      28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 
      28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 
      28.5, 28.5, 28.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 
      27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 
      27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 
      27.5, 27.5, 27.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 
      26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 
      26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 
      26.5, 26.5, 26.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 
      25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 
      25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 
      25.5, 25.5, 25.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 
      24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 
      24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 
      24.5, 24.5, 24.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 
      23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 
      23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 
      23.5, 23.5, 23.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 
      22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 
      22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 
      22.5, 22.5, 22.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 
      21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 
      21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 
      21.5, 21.5, 21.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 
      20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 
      20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 
      20.5, 20.5, 20.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 
      19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 
      19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 
      19.5, 19.5, 19.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 
      18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 
      18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 
      18.5, 18.5, 18.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 
      17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 
      17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 
      17.5, 17.5, 17.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 
      16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 
      16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 
      16.5, 16.5, 16.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 
      15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 
      15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 
      15.5, 15.5, 15.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 
      14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 
      14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 
      14.5, 14.5, 14.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 
      13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 
      13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 
      13.5, 13.5, 13.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
      12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
      12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
      12.5, 12.5, 12.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 
      11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 
      11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 
      11.5, 11.5, 11.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 
      10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 
      10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 
      10.5, 10.5, 10.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 
      9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 
      9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 8.5, 8.5, 
      8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 
      8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 
      8.5, 8.5, 8.5, 8.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 
      7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 
      7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 6.5, 6.5, 
      6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 
      6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 
      6.5, 6.5, 6.5, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 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, 3, 3, 3, 2, 2, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
      2, 2, 2, 1, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 2, 3, 
      3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 
      3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 
      2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 3, 3, 2, 3, 2, 
      3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 3, 3, 1, 
      3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 2, 2, 
      2, 2, 2, 2, 2, 1, 1, 3, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2, 2, 
      2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 2, 
      2, 2, 1, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 
      3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 2, 2))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      points <- raster_to_points(landscape)[, 2:4]
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, verbose, points = NULL) 
  {
      if (class(landscape) != "matrix") {
          points <- raster_to_points(landscape)[, 2:4]
          landscape <- raster::as.matrix(landscape)
      }
      classes <- get_unique_values(landscape)[[1]]
      enn_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          np_class <- max(landscape_labeled, na.rm = TRUE)
          if (np_class == 1) {
              enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
              if (verbose) {
                  warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                    call. = FALSE)
              }
          }
          else {
              class_boundaries <- get_boundaries(landscape_labeled, 
                  directions = 4, as_NA = TRUE)[[1]]
              class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
              class_boundaries <- t(class_boundaries)
              points <- points[which(!is.na(class_boundaries)), 
                  ]
              points[, 3] <- class_boundaries[!is.na(class_boundaries)]
              ord <- order(as.matrix(points)[, 1])
              num <- seq_along(ord)
              rank <- match(num, ord)
              res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
                  ])
              min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
                  3]))
              tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
                  2], id = min_dist[, 3])
              enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 
                  3], FUN = min)
          }
          tibble::tibble(class = patches_class, value = enn$dist)
      }))
      tibble::tibble(level = "patch", class = as.integer(enn_patch$class), 
          id = as.integer(seq_len(nrow(enn_patch))), metric = "enn", 
          value = as.double(enn_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L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2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, verbose = FALSE, 
      points = c(0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 
      10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 
      20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 
      0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 
      12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 
      22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 
      2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 
      13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 
      23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 
      3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 
      14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 
      24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 
      5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 
      16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 
      26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 
      7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 
      17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 
      27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 
      8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 
      18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 
      28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 
      9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 
      19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 
      29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 
      11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 
      21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 
      1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 
      12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 
      22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 
      2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 
      13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 
      23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 
      3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 
      14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 
      24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 
      5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 
      16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 
      26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 
      7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 
      17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 
      27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 
      8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 
      18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 
      28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 
      9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 
      19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 
      29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 
      11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 
      21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 
      1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 
      12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 
      22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 
      2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 
      13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 
      23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 
      3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 
      14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 
      24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 
      5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 
      16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 
      26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 
      7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 
      17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 
      27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 
      8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 
      18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 
      28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 
      9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 
      19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 
      29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 
      11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 
      21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 
      1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 
      12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 
      22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 
      2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 
      13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 
      23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 
      3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 
      14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 
      24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 
      5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 
      16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 
      26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 
      7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 
      17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 
      27.5, 28.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 
      29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 
      29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 
      29.5, 29.5, 29.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 
      28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 
      28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 
      28.5, 28.5, 28.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 
      27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 
      27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 
      27.5, 27.5, 27.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 
      26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 
      26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 
      26.5, 26.5, 26.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 
      25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 
      25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 
      25.5, 25.5, 25.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 
      24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 
      24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 
      24.5, 24.5, 24.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 
      23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 
      23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 
      23.5, 23.5, 23.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 
      22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 
      22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 
      22.5, 22.5, 22.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 
      21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 
      21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 
      21.5, 21.5, 21.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 
      20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 
      20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 
      20.5, 20.5, 20.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 
      19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 
      19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 
      19.5, 19.5, 19.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 
      18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 
      18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 
      18.5, 18.5, 18.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 
      17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 
      17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 
      17.5, 17.5, 17.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 
      16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 
      16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 
      16.5, 16.5, 16.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 
      15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 
      15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 
      15.5, 15.5, 15.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 
      14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 
      14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 
      14.5, 14.5, 14.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 
      13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 
      13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 
      13.5, 13.5, 13.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
      12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
      12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
      12.5, 12.5, 12.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 
      11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 
      11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 
      11.5, 11.5, 11.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 
      10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 
      10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 
      10.5, 10.5, 10.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 
      9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 
      9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 8.5, 8.5, 
      8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 
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2, 2, 3, 3, 3, 2, 2))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, what = c("lsm_p_enn", "lsm_c_ed"), 
      verbose = FALSE)
  where 13 at testthat/test-calculate-lsm.R#45: calculate_lsm(landscape, what = c("lsm_p_enn", "lsm_c_ed"), verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 25 at testthat/test-calculate-lsm.R#43: test_that("calculate_lsm can take specific metrics", {
      specific_metrics <- calculate_lsm(landscape, what = c("lsm_p_enn", 
          "lsm_c_ed"), verbose = FALSE)
      expect_true(all(specific_metrics$metric %in% c("ed", "enn")))
      expect_is(specific_metrics, "tbl_df")
      expect_true(ncol(specific_metrics) > 0)
  })
  where 26: eval(code, test_env)
  where 27: eval(code, test_env)
  where 28: 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 29: doTryCatch(return(expr), name, parentenv, handler)
  where 30: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 31: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 32: doTryCatch(return(expr), name, parentenv, handler)
  where 33: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 34: tryCatchList(expr, classes, parentenv, handlers)
  where 35: 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 36: test_code(NULL, exprs, env)
  where 37: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 38: force(code)
  where 39: doWithOneRestart(return(expr), restart)
  where 40: withOneRestart(expr, restarts[[1L]])
  where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 42: 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 43: FUN(X[[i]], ...)
  where 44: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 45: force(code)
  where 46: doWithOneRestart(return(expr), restart)
  where 47: withOneRestart(expr, restarts[[1L]])
  where 48: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 49: 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 50: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 51: 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 52: 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 53: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, verbose, points = NULL) 
  {
      if (class(landscape) != "matrix") {
          points <- raster_to_points(landscape)[, 2:4]
          landscape <- raster::as.matrix(landscape)
      }
      classes <- get_unique_values(landscape)[[1]]
      enn_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          np_class <- max(landscape_labeled, na.rm = TRUE)
          if (np_class == 1) {
              enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
              if (verbose) {
                  warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                    call. = FALSE)
              }
          }
          else {
              class_boundaries <- get_boundaries(landscape_labeled, 
                  directions = 4, as_NA = TRUE)[[1]]
              class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
              class_boundaries <- t(class_boundaries)
              points <- points[which(!is.na(class_boundaries)), 
                  ]
              points[, 3] <- class_boundaries[!is.na(class_boundaries)]
              ord <- order(as.matrix(points)[, 1])
              num <- seq_along(ord)
              rank <- match(num, ord)
              res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
                  ])
              min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
                  3]))
              tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
                  2], id = min_dist[, 3])
              enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 
                  3], FUN = min)
          }
          tibble::tibble(class = patches_class, value = enn$dist)
      }))
      tibble::tibble(level = "patch", class = as.integer(enn_patch$class), 
          id = as.integer(seq_len(nrow(enn_patch))), metric = "enn", 
          value = as.double(enn_patch$value))
  }
  <bytecode: 0x812dc18>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_enn_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 5. Error: calculate_lsm can take specific metrics (@test-calculate-lsm.R#45) 
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::calculate_lsm(...)
    2. landscapemetrics:::calculate_lsm.RasterLayer(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. base::lapply(...)
    7. landscapemetrics:::FUN(X[[i]], ...)
    8. base::tryCatch(...)
    9. base:::tryCatchList(expr, classes, parentenv, handlers)
   10. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   11. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L,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 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L,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 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, level = "patch", verbose = FALSE)
  where 13 at testthat/test-calculate-lsm.R#56: calculate_lsm(landscape, level = "patch", verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 25 at testthat/test-calculate-lsm.R#54: test_that("calculate_lsm can take level argument", {
      specific_metrics_patch <- calculate_lsm(landscape, level = "patch", 
          verbose = FALSE)
      specific_metrics_class <- calculate_lsm(landscape, level = "class", 
          verbose = FALSE)
      specific_metrics_landscape <- calculate_lsm(landscape, level = "landscape", 
          verbose = FALSE)
      expect_true(all(specific_metrics_patch$level == "patch"))
      expect_true(all(specific_metrics_class$level == "class"))
      expect_true(all(specific_metrics_landscape$level == "landscape"))
  })
  where 26: eval(code, test_env)
  where 27: eval(code, test_env)
  where 28: 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 29: doTryCatch(return(expr), name, parentenv, handler)
  where 30: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 31: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 32: doTryCatch(return(expr), name, parentenv, handler)
  where 33: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 34: tryCatchList(expr, classes, parentenv, handlers)
  where 35: 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 36: test_code(NULL, exprs, env)
  where 37: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 38: force(code)
  where 39: doWithOneRestart(return(expr), restart)
  where 40: withOneRestart(expr, restarts[[1L]])
  where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 42: 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 43: FUN(X[[i]], ...)
  where 44: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 45: force(code)
  where 46: doWithOneRestart(return(expr), restart)
  where 47: withOneRestart(expr, restarts[[1L]])
  where 48: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 49: 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 50: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 51: 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 52: 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 53: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 6. Error: calculate_lsm can take level argument (@test-calculate-lsm.R#56)  -
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::calculate_lsm(landscape, level = "patch", verbose = FALSE)
    2. landscapemetrics:::calculate_lsm.RasterLayer(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. base::lapply(...)
    7. landscapemetrics:::FUN(X[[i]], ...)
    8. base::tryCatch(...)
    9. base:::tryCatchList(expr, classes, parentenv, handlers)
   10. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   11. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 
  1L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 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), directions = 8, resolution = c(1, 
  1))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 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, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, metric = "area", verbose = FALSE)
  where 13 at testthat/test-calculate-lsm.R#76: calculate_lsm(landscape, metric = "area", verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 25 at testthat/test-calculate-lsm.R#74: test_that("calculate_lsm can take metric argument", {
      specific_metrics_area <- calculate_lsm(landscape, metric = "area", 
          verbose = FALSE)
      metrics <- vapply(strsplit(specific_metrics_area$metric, 
          split = "_"), FUN = function(x) x[1], FUN.VALUE = character(1))
      expect_true(all(metrics == "area"))
  })
  where 26: eval(code, test_env)
  where 27: eval(code, test_env)
  where 28: 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 29: doTryCatch(return(expr), name, parentenv, handler)
  where 30: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 31: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 32: doTryCatch(return(expr), name, parentenv, handler)
  where 33: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 34: tryCatchList(expr, classes, parentenv, handlers)
  where 35: 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 36: test_code(NULL, exprs, env)
  where 37: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 38: force(code)
  where 39: doWithOneRestart(return(expr), restart)
  where 40: withOneRestart(expr, restarts[[1L]])
  where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 42: 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 43: FUN(X[[i]], ...)
  where 44: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 45: force(code)
  where 46: doWithOneRestart(return(expr), restart)
  where 47: withOneRestart(expr, restarts[[1L]])
  where 48: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 49: 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 50: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 51: 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 52: 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 53: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 7. Error: calculate_lsm can take metric argument (@test-calculate-lsm.R#76)  
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::calculate_lsm(landscape, metric = "area", verbose = FALSE)
    2. landscapemetrics:::calculate_lsm.RasterLayer(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. base::lapply(...)
    7. landscapemetrics:::FUN(X[[i]], ...)
    8. base::tryCatch(...)
    9. base:::tryCatchList(expr, classes, parentenv, handlers)
   10. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   11. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, consider_boundary, edge_depth, 
      resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      classes <- get_unique_values(landscape)[[1]]
      core <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          class_edge <- get_boundaries(landscape_labeled, directions = 4, 
              consider_boundary = consider_boundary)[[1]]
          cells_edge_patch <- table(landscape_labeled[class_edge == 
              1])
          if (edge_depth > 1) {
              for (i in seq_len(edge_depth - 1)) {
                  class_edge[class_edge == 1] <- NA
                  class_edge <- get_boundaries(class_edge, directions = 4, 
                    consider_boundary = consider_boundary)[[1]]
                  cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                    1], nbins = length(cells_edge_patch))
              }
          }
          cells_patch <- table(landscape_labeled)
          if (dim(cells_edge_patch) == 0) {
              cells_edge_patch <- 0
          }
          core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
          tibble::tibble(class = patches_class, value = core_area)
      }))
      tibble::tibble(level = "patch", class = as.integer(core$class), 
          id = as.integer(seq_len(nrow(core))), metric = "core", 
          value = as.double(core$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 
  1L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L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3L, 3L, 3L, 2L, 2L, 2L), directions = 8, consider_boundary = FALSE, 
      edge_depth = 1, resolution = c(1, 1))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, consider_boundary, edge_depth, 
      resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      classes <- get_unique_values(landscape)[[1]]
      core <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          class_edge <- get_boundaries(landscape_labeled, directions = 4, 
              consider_boundary = consider_boundary)[[1]]
          cells_edge_patch <- table(landscape_labeled[class_edge == 
              1])
          if (edge_depth > 1) {
              for (i in seq_len(edge_depth - 1)) {
                  class_edge[class_edge == 1] <- NA
                  class_edge <- get_boundaries(class_edge, directions = 4, 
                    consider_boundary = consider_boundary)[[1]]
                  cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                    1], nbins = length(cells_edge_patch))
              }
          }
          cells_patch <- table(landscape_labeled)
          if (dim(cells_edge_patch) == 0) {
              cells_edge_patch <- 0
          }
          core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
          tibble::tibble(class = patches_class, value = core_area)
      }))
      tibble::tibble(level = "patch", class = as.integer(core$class), 
          id = as.integer(seq_len(nrow(core))), metric = "core", 
          value = as.double(core$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L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3L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, consider_boundary = FALSE, 
      edge_depth = 1, resolution = c(1, 1))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, name = "core area", verbose = FALSE)
  where 13 at testthat/test-calculate-lsm.R#89: calculate_lsm(landscape, name = "core area", verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 25 at testthat/test-calculate-lsm.R#87: test_that("calculate_lsm can take name argument", {
      specific_metrics_name <- calculate_lsm(landscape, name = "core area", 
          verbose = FALSE)
      metrics <- vapply(strsplit(specific_metrics_name$metric, 
          split = "_"), FUN = function(x) x[1], FUN.VALUE = character(1))
      expect_true(all(metrics == "core"))
  })
  where 26: eval(code, test_env)
  where 27: eval(code, test_env)
  where 28: 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 29: doTryCatch(return(expr), name, parentenv, handler)
  where 30: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 31: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 32: doTryCatch(return(expr), name, parentenv, handler)
  where 33: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 34: tryCatchList(expr, classes, parentenv, handlers)
  where 35: 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 36: test_code(NULL, exprs, env)
  where 37: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 38: force(code)
  where 39: doWithOneRestart(return(expr), restart)
  where 40: withOneRestart(expr, restarts[[1L]])
  where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 42: 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 43: FUN(X[[i]], ...)
  where 44: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 45: force(code)
  where 46: doWithOneRestart(return(expr), restart)
  where 47: withOneRestart(expr, restarts[[1L]])
  where 48: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 49: 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 50: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 51: 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 52: 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 53: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, consider_boundary, edge_depth, 
      resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      classes <- get_unique_values(landscape)[[1]]
      core <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          class_edge <- get_boundaries(landscape_labeled, directions = 4, 
              consider_boundary = consider_boundary)[[1]]
          cells_edge_patch <- table(landscape_labeled[class_edge == 
              1])
          if (edge_depth > 1) {
              for (i in seq_len(edge_depth - 1)) {
                  class_edge[class_edge == 1] <- NA
                  class_edge <- get_boundaries(class_edge, directions = 4, 
                    consider_boundary = consider_boundary)[[1]]
                  cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                    1], nbins = length(cells_edge_patch))
              }
          }
          cells_patch <- table(landscape_labeled)
          if (dim(cells_edge_patch) == 0) {
              cells_edge_patch <- 0
          }
          core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
          tibble::tibble(class = patches_class, value = core_area)
      }))
      tibble::tibble(level = "patch", class = as.integer(core$class), 
          id = as.integer(seq_len(nrow(core))), metric = "core", 
          value = as.double(core$value))
  }
  <bytecode: 0x823c7e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_core_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 8. Error: calculate_lsm can take name argument (@test-calculate-lsm.R#89)  --
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::calculate_lsm(...)
    2. landscapemetrics:::calculate_lsm.RasterLayer(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. base::lapply(...)
    7. landscapemetrics:::FUN(X[[i]], ...)
    8. base::tryCatch(...)
    9. base:::tryCatchList(expr, classes, parentenv, handlers)
   10. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   11. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, verbose, points = NULL) 
  {
      if (class(landscape) != "matrix") {
          points <- raster_to_points(landscape)[, 2:4]
          landscape <- raster::as.matrix(landscape)
      }
      classes <- get_unique_values(landscape)[[1]]
      enn_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          np_class <- max(landscape_labeled, na.rm = TRUE)
          if (np_class == 1) {
              enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
              if (verbose) {
                  warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                    call. = FALSE)
              }
          }
          else {
              class_boundaries <- get_boundaries(landscape_labeled, 
                  directions = 4, as_NA = TRUE)[[1]]
              class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
              class_boundaries <- t(class_boundaries)
              points <- points[which(!is.na(class_boundaries)), 
                  ]
              points[, 3] <- class_boundaries[!is.na(class_boundaries)]
              ord <- order(as.matrix(points)[, 1])
              num <- seq_along(ord)
              rank <- match(num, ord)
              res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
                  ])
              min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
                  3]))
              tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
                  2], id = min_dist[, 3])
              enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 
                  3], FUN = min)
          }
          tibble::tibble(class = patches_class, value = enn$dist)
      }))
      tibble::tibble(level = "patch", class = as.integer(enn_patch$class), 
          id = as.integer(seq_len(nrow(enn_patch))), metric = "enn", 
          value = as.double(enn_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 
  1L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 
  2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 3L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, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 
      12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 
      22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 
      2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 
      13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 
      23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 
      3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 
      14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 
      24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 
      5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 
      16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 
      26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 
      7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 
      17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 
      27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 
      8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 
      18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 
      28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 
      9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 
      19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 
      29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 
      11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 
      21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 
      1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 
      12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 
      22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 
      2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 
      13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 
      23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 
      3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 
      14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 
      24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 
      5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 
      16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 
      26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 
      7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 
      17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 
      27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 
      8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 
      18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 
      28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 
      9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 
      19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 
      29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 
      11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 
      21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 
      1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 
      12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 
      22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 
      2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 
      13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 
      23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 
      3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 
      14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 
      24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 
      5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 
      16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 
      26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 
      7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 
      17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 
      27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 
      8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 
      18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 
      28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 
      9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 
      19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 
      29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 
      11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 
      21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 
      1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 
      12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 
      22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 
      2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 
      13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 
      23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 
      3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 
      14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 
      24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 
      5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 
      16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 
      26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 
      7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 
      17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 
      27.5, 28.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 
      29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 
      29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 
      29.5, 29.5, 29.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 
      28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 
      28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 
      28.5, 28.5, 28.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 
      27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 
      27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 
      27.5, 27.5, 27.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 
      26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 
      26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 
      26.5, 26.5, 26.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 
      25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 
      25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 
      25.5, 25.5, 25.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 
      24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 
      24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 
      24.5, 24.5, 24.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 
      23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 
      23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 
      23.5, 23.5, 23.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 
      22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 
      22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 
      22.5, 22.5, 22.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 
      21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 
      21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 
      21.5, 21.5, 21.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 
      20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 
      20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 
      20.5, 20.5, 20.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 
      19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 
      19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 
      19.5, 19.5, 19.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 
      18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 
      18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 
      18.5, 18.5, 18.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 
      17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 
      17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 
      17.5, 17.5, 17.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 
      16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 
      16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 
      16.5, 16.5, 16.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 
      15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 
      15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 
      15.5, 15.5, 15.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 
      14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 
      14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 
      14.5, 14.5, 14.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 
      13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 
      13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 
      13.5, 13.5, 13.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
      12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
      12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
      12.5, 12.5, 12.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 
      11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 
      11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 
      11.5, 11.5, 11.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 
      10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 
      10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 
      10.5, 10.5, 10.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 
      9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 
      9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 8.5, 8.5, 
      8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 
      8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 
      8.5, 8.5, 8.5, 8.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 
      7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 
      7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 6.5, 6.5, 
      6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 
      6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6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 1, 1, 1, 1, 
      1, 1, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
      1, 1, 3, 3, 3, 3, 2, 2, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
      2, 2, 2, 1, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 2, 3, 
      3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 
      3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 
      2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 3, 3, 2, 3, 2, 
      3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 3, 3, 1, 
      3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 2, 2, 
      2, 2, 2, 2, 2, 1, 1, 3, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2, 2, 
      2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 2, 
      2, 2, 1, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 
      3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 2, 2))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      points <- raster_to_points(landscape)[, 2:4]
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, verbose, points = NULL) 
  {
      if (class(landscape) != "matrix") {
          points <- raster_to_points(landscape)[, 2:4]
          landscape <- raster::as.matrix(landscape)
      }
      classes <- get_unique_values(landscape)[[1]]
      enn_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          np_class <- max(landscape_labeled, na.rm = TRUE)
          if (np_class == 1) {
              enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
              if (verbose) {
                  warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                    call. = FALSE)
              }
          }
          else {
              class_boundaries <- get_boundaries(landscape_labeled, 
                  directions = 4, as_NA = TRUE)[[1]]
              class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
              class_boundaries <- t(class_boundaries)
              points <- points[which(!is.na(class_boundaries)), 
                  ]
              points[, 3] <- class_boundaries[!is.na(class_boundaries)]
              ord <- order(as.matrix(points)[, 1])
              num <- seq_along(ord)
              rank <- match(num, ord)
              res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
                  ])
              min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
                  3]))
              tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
                  2], id = min_dist[, 3])
              enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 
                  3], FUN = min)
          }
          tibble::tibble(class = patches_class, value = enn$dist)
      }))
      tibble::tibble(level = "patch", class = as.integer(enn_patch$class), 
          id = as.integer(seq_len(nrow(enn_patch))), metric = "enn", 
          value = as.double(enn_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L,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L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, verbose = FALSE, 
      points = c(0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 
      10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 
      20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 
      0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 
      12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 
      22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 
      2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 
      13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 
      23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 
      3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 
      14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 
      24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 
      5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 
      16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 
      26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 
      7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 
      17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 
      27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 
      8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 
      18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 
      28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 
      9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 
      19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 
      29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 
      11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 
      21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 
      1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 
      12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 
      22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 
      2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 
      13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 
      23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 
      3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 
      14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 
      24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 
      5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 
      16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 
      26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 
      7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 
      17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 
      27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 
      8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 
      18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 
      28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 
      9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 
      19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 
      29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 
      11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 
      21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 
      1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 
      12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 
      22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 
      2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 
      13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 
      23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 
      3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 
      14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 
      24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 
      5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 
      16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 
      26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 
      7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 
      17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 
      27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 
      8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 
      18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 
      28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 
      9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 
      19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 
      29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 
      11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 
      21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 
      1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 
      12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 
      22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 
      2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 
      13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 
      23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 
      3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 
      14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 
      24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 
      5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 
      16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 
      26.5, 27.5, 28.5, 29.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 
      7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 
      17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 
      27.5, 28.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 
      29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 
      29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 29.5, 
      29.5, 29.5, 29.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 
      28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 
      28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 28.5, 
      28.5, 28.5, 28.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 
      27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 
      27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 
      27.5, 27.5, 27.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 
      26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 
      26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 26.5, 
      26.5, 26.5, 26.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 
      25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 
      25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 
      25.5, 25.5, 25.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 
      24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 
      24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 
      24.5, 24.5, 24.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 
      23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 
      23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 
      23.5, 23.5, 23.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 
      22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 
      22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 
      22.5, 22.5, 22.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 
      21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 
      21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 
      21.5, 21.5, 21.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 
      20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 
      20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 
      20.5, 20.5, 20.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 
      19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 
      19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 
      19.5, 19.5, 19.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 
      18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 
      18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 
      18.5, 18.5, 18.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 
      17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 
      17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 
      17.5, 17.5, 17.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 
      16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 
      16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 
      16.5, 16.5, 16.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 
      15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 
      15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 
      15.5, 15.5, 15.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 
      14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 
      14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 
      14.5, 14.5, 14.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 
      13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 
      13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 
      13.5, 13.5, 13.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
      12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
      12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
      12.5, 12.5, 12.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 
      11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 
      11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 
      11.5, 11.5, 11.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 
      10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 
      10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 
      10.5, 10.5, 10.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 
      9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 
      9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.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, 
      2, 2, 1, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 
      3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 2, 2))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, type = "aggregation metric", 
      full_name = TRUE, verbose = FALSE)
  where 13 at testthat/test-calculate-lsm.R#101: calculate_lsm(landscape, type = "aggregation metric", full_name = TRUE, 
      verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 25 at testthat/test-calculate-lsm.R#99: test_that("calculate_lsm can take type argument", {
      specific_metrics_type <- calculate_lsm(landscape, type = "aggregation metric", 
          full_name = TRUE, verbose = FALSE)
      expect_true(all(specific_metrics_type$type == "aggregation metric"))
  })
  where 26: eval(code, test_env)
  where 27: eval(code, test_env)
  where 28: 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 29: doTryCatch(return(expr), name, parentenv, handler)
  where 30: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 31: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 32: doTryCatch(return(expr), name, parentenv, handler)
  where 33: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 34: tryCatchList(expr, classes, parentenv, handlers)
  where 35: 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 36: test_code(NULL, exprs, env)
  where 37: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 38: force(code)
  where 39: doWithOneRestart(return(expr), restart)
  where 40: withOneRestart(expr, restarts[[1L]])
  where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 42: 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 43: FUN(X[[i]], ...)
  where 44: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 45: force(code)
  where 46: doWithOneRestart(return(expr), restart)
  where 47: withOneRestart(expr, restarts[[1L]])
  where 48: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 49: 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 50: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 51: 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 52: 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 53: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, verbose, points = NULL) 
  {
      if (class(landscape) != "matrix") {
          points <- raster_to_points(landscape)[, 2:4]
          landscape <- raster::as.matrix(landscape)
      }
      classes <- get_unique_values(landscape)[[1]]
      enn_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          np_class <- max(landscape_labeled, na.rm = TRUE)
          if (np_class == 1) {
              enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
              if (verbose) {
                  warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                    call. = FALSE)
              }
          }
          else {
              class_boundaries <- get_boundaries(landscape_labeled, 
                  directions = 4, as_NA = TRUE)[[1]]
              class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
              class_boundaries <- t(class_boundaries)
              points <- points[which(!is.na(class_boundaries)), 
                  ]
              points[, 3] <- class_boundaries[!is.na(class_boundaries)]
              ord <- order(as.matrix(points)[, 1])
              num <- seq_along(ord)
              rank <- match(num, ord)
              res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
                  ])
              min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
                  3]))
              tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
                  2], id = min_dist[, 3])
              enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 
                  3], FUN = min)
          }
          tibble::tibble(class = patches_class, value = enn$dist)
      }))
      tibble::tibble(level = "patch", class = as.integer(enn_patch$class), 
          id = as.integer(seq_len(nrow(enn_patch))), metric = "enn", 
          value = as.double(enn_patch$value))
  }
  <bytecode: 0x812dc18>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_enn_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 9. Error: calculate_lsm can take type argument (@test-calculate-lsm.R#101)  -
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::calculate_lsm(...)
    2. landscapemetrics:::calculate_lsm.RasterLayer(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. base::lapply(...)
    7. landscapemetrics:::FUN(X[[i]], ...)
    8. base::tryCatch(...)
    9. base:::tryCatchList(expr, classes, parentenv, handlers)
   10. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   11. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: (function (landscape, directions, resolution = NULL) 
  {
      patch_area <- lsm_p_area_calc(landscape, directions = directions, 
          resolution = resolution)
      total_area <- sum(patch_area$value)
      tibble::tibble(level = "landscape", class = as.integer(NA), 
          id = as.integer(NA), metric = "ta", value = as.double(total_area))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L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, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
  where 3: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 4: doTryCatch(return(expr), name, parentenv, handler)
  where 5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 6: tryCatchList(expr, classes, parentenv, handlers)
  where 7: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 8: FUN(X[[i]], ...)
  where 9: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 10: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 13: calculate_lsm.RasterLayer(landscape, what = "lsm_l_ta", verbose = FALSE)
  where 14: calculate_lsm(landscape, what = "lsm_l_ta", verbose = FALSE)
  where 15: eval_bare(expr, quo_get_env(quo))
  where 16: quasi_label(enquo(object), label, arg = "object")
  where 17 at testthat/test-calculate-lsm.R#111: expect_is(calculate_lsm(landscape, what = "lsm_l_ta", verbose = FALSE), 
      "tbl_df")
  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(desc, code, env = parent.frame())
  where 29 at testthat/test-calculate-lsm.R#109: test_that("calculate_lsm can take different raster inputs", {
      expect_is(calculate_lsm(landscape, what = "lsm_l_ta", verbose = FALSE), 
          "tbl_df")
      expect_is(calculate_lsm(landscape_stack, what = "lsm_l_ta", 
          verbose = FALSE), "tbl_df")
      expect_is(calculate_lsm(landscape_brick, what = "lsm_l_ta", 
          verbose = FALSE), "tbl_df")
      expect_is(calculate_lsm(landscape_list, what = "lsm_l_ta", 
          verbose = FALSE), "tbl_df")
  })
  where 30: eval(code, test_env)
  where 31: eval(code, test_env)
  where 32: 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 33: doTryCatch(return(expr), name, parentenv, handler)
  where 34: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 35: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 36: doTryCatch(return(expr), name, parentenv, handler)
  where 37: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 38: tryCatchList(expr, classes, parentenv, handlers)
  where 39: 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 40: test_code(NULL, exprs, env)
  where 41: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 42: force(code)
  where 43: doWithOneRestart(return(expr), restart)
  where 44: withOneRestart(expr, restarts[[1L]])
  where 45: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 46: 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 47: FUN(X[[i]], ...)
  where 48: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 49: force(code)
  where 50: doWithOneRestart(return(expr), restart)
  where 51: withOneRestart(expr, restarts[[1L]])
  where 52: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 53: 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 54: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 55: 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 56: 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 57: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 10. Error: calculate_lsm can take different raster inputs (@test-calculate-ls
  the condition has length > 1
  Backtrace:
    1. testthat::expect_is(...)
    5. landscapemetrics:::calculate_lsm.RasterLayer(...)
    6. base::lapply(...)
    7. landscapemetrics:::FUN(X[[i]], ...)
    9. base::lapply(...)
   10. landscapemetrics:::FUN(X[[i]], ...)
   11. base::tryCatch(...)
   12. base:::tryCatchList(expr, classes, parentenv, handlers)
   13. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   14. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 
  1L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3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matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 
  1L, 2L, 3L, 3L, 3L, 3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L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: calculate_lsm_internal(landscape = landscape[[x]], level = level, 
      metric = metric, name = name, type = type, what = what, directions = directions, 
      count_boundary = count_boundary, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = FALSE)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = seq_along(landscape), FUN = function(x) {
      if (progress) {
          message("\r> Progress nlayers: ", x, "/", length(landscape), 
              appendLF = FALSE)
      }
      calculate_lsm_internal(landscape = landscape[[x]], level = level, 
          metric = metric, name = name, type = type, what = what, 
          directions = directions, count_boundary = count_boundary, 
          consider_boundary = consider_boundary, edge_depth = edge_depth, 
          classes_max = classes_max, neighbourhood = neighbourhood, 
          ordered = ordered, base = base, full_name = full_name, 
          verbose = verbose, progress = FALSE)
  })
  where 13: calculate_lsm.RasterStack(landscape_stack, level = c("patch", 
      "class"), type = "area and edge metric", verbose = FALSE)
  where 14 at testthat/test-calculate_correlation.R#5: calculate_lsm(landscape_stack, level = c("patch", "class"), type = "area and edge metric", 
      verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 26 at testthat/test-calculate_correlation.R#3: test_that("calculate_correlation returns a list if two levels are present", 
      {
          metrics <- calculate_lsm(landscape_stack, level = c("patch", 
              "class"), type = "area and edge metric", verbose = FALSE)
          result <- calculate_correlation(metrics, method = "pearson")
          expect_length(result, n = 2)
          expect_true(all(names(result) == c("patch", "class")))
      })
  where 27: eval(code, test_env)
  where 28: eval(code, test_env)
  where 29: 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 30: doTryCatch(return(expr), name, parentenv, handler)
  where 31: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 32: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 33: doTryCatch(return(expr), name, parentenv, handler)
  where 34: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 35: tryCatchList(expr, classes, parentenv, handlers)
  where 36: 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 37: test_code(NULL, exprs, env)
  where 38: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 39: force(code)
  where 40: doWithOneRestart(return(expr), restart)
  where 41: withOneRestart(expr, restarts[[1L]])
  where 42: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 43: 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 44: FUN(X[[i]], ...)
  where 45: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 46: force(code)
  where 47: doWithOneRestart(return(expr), restart)
  where 48: withOneRestart(expr, restarts[[1L]])
  where 49: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 50: 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 51: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 52: 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 53: 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 54: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 11. Error: calculate_correlation returns a list if two levels are present (@t
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::calculate_lsm(...)
    2. landscapemetrics:::calculate_lsm.RasterStack(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::calculate_lsm_internal(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
    9. base::tryCatch(...)
   10. base:::tryCatchList(expr, classes, parentenv, handlers)
   11. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   12. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      patch_area <- lsm_p_area_calc(landscape, directions = directions, 
          resolution = resolution)
      msidi <- stats::aggregate(x = patch_area[, 5], by = patch_area[, 
          2], FUN = sum)
      msidi <- -log(sum((msidi$value/sum(msidi$value))^2))
      tibble::tibble(level = "landscape", class = as.integer(NA), 
          id = as.integer(NA), metric = "msidi", value = as.double(msidi))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 
  1L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 
  2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 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, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 1L, 1L, 1L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 1L, 1L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 1L, 1L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      patch_area <- lsm_p_area_calc(landscape, directions = directions, 
          resolution = resolution)
      msidi <- stats::aggregate(x = patch_area[, 5], by = patch_area[, 
          2], FUN = sum)
      msidi <- -log(sum((msidi$value/sum(msidi$value))^2))
      tibble::tibble(level = "landscape", class = as.integer(NA), 
          id = as.integer(NA), metric = "msidi", value = as.double(msidi))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 
  1L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 
  2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 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, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 1L, 1L, 1L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 1L, 1L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 1L, 1L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: calculate_lsm_internal(landscape = landscape[[x]], level = level, 
      metric = metric, name = name, type = type, what = what, directions = directions, 
      count_boundary = count_boundary, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = FALSE)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = seq_along(landscape), FUN = function(x) {
      if (progress) {
          message("\r> Progress nlayers: ", x, "/", length(landscape), 
              appendLF = FALSE)
      }
      calculate_lsm_internal(landscape = landscape[[x]], level = level, 
          metric = metric, name = name, type = type, what = what, 
          directions = directions, count_boundary = count_boundary, 
          consider_boundary = consider_boundary, edge_depth = edge_depth, 
          classes_max = classes_max, neighbourhood = neighbourhood, 
          ordered = ordered, base = base, full_name = full_name, 
          verbose = verbose, progress = FALSE)
  })
  where 13: calculate_lsm.RasterStack(landscape_stack, level = "landscape", 
      type = "diversity metric", classes_max = 3, verbose = FALSE)
  where 14 at testthat/test-calculate_correlation.R#18: calculate_lsm(landscape_stack, level = "landscape", type = "diversity metric", 
      classes_max = 3, verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 26 at testthat/test-calculate_correlation.R#16: test_that("calculate_correlation works on landscape level for RasterStacks", 
      {
          metrics <- calculate_lsm(landscape_stack, level = "landscape", 
              type = "diversity metric", classes_max = 3, verbose = FALSE)
          result <- calculate_correlation(metrics, method = "pearson", 
              simplify = TRUE)
          expect_is(result, "tbl_df")
      })
  where 27: eval(code, test_env)
  where 28: eval(code, test_env)
  where 29: 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 30: doTryCatch(return(expr), name, parentenv, handler)
  where 31: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 32: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 33: doTryCatch(return(expr), name, parentenv, handler)
  where 34: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 35: tryCatchList(expr, classes, parentenv, handlers)
  where 36: 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 37: test_code(NULL, exprs, env)
  where 38: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 39: force(code)
  where 40: doWithOneRestart(return(expr), restart)
  where 41: withOneRestart(expr, restarts[[1L]])
  where 42: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 43: 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 44: FUN(X[[i]], ...)
  where 45: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 46: force(code)
  where 47: doWithOneRestart(return(expr), restart)
  where 48: withOneRestart(expr, restarts[[1L]])
  where 49: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 50: 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 51: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 52: 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 53: 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 54: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      patch_area <- lsm_p_area_calc(landscape, directions = directions, 
          resolution = resolution)
      msidi <- stats::aggregate(x = patch_area[, 5], by = patch_area[, 
          2], FUN = sum)
      msidi <- -log(sum((msidi$value/sum(msidi$value))^2))
      tibble::tibble(level = "landscape", class = as.integer(NA), 
          id = as.integer(NA), metric = "msidi", value = as.double(msidi))
  }
  <bytecode: 0x807a840>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_l_msidi_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 12. Error: calculate_correlation works on landscape level for RasterStacks (@
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::calculate_lsm(...)
    2. landscapemetrics:::calculate_lsm.RasterStack(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::calculate_lsm_internal(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
    9. base::tryCatch(...)
   10. base:::tryCatchList(expr, classes, parentenv, handlers)
   11. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   12. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 
  1L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 
  2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 3L, 3L, 
  3L, 2L, 3L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 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, 1L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 1L, 1L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 
  1L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 
  2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 3L, 3L, 
  3L, 2L, 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, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 1L, 1L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 1L, 1L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: calculate_lsm_internal(landscape = landscape[[x]], level = level, 
      metric = metric, name = name, type = type, what = what, directions = directions, 
      count_boundary = count_boundary, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = FALSE)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = seq_along(landscape), FUN = function(x) {
      if (progress) {
          message("\r> Progress nlayers: ", x, "/", length(landscape), 
              appendLF = FALSE)
      }
      calculate_lsm_internal(landscape = landscape[[x]], level = level, 
          metric = metric, name = name, type = type, what = what, 
          directions = directions, count_boundary = count_boundary, 
          consider_boundary = consider_boundary, edge_depth = edge_depth, 
          classes_max = classes_max, neighbourhood = neighbourhood, 
          ordered = ordered, base = base, full_name = full_name, 
          verbose = verbose, progress = FALSE)
  })
  where 13: calculate_lsm.RasterStack(landscape_stack, level = c("patch", 
      "class"), type = "area and edge metric", verbose = FALSE)
  where 14 at testthat/test-calculate_correlation.R#31: calculate_lsm(landscape_stack, level = c("patch", "class"), type = "area and edge metric", 
      verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 26 at testthat/test-calculate_correlation.R#29: test_that("calculate_correlation returns warnings", {
      metrics <- calculate_lsm(landscape_stack, level = c("patch", 
          "class"), type = "area and edge metric", verbose = FALSE)
      expect_warning(calculate_correlation(metrics, method = "pearson", 
          simplify = TRUE), regexp = "Simplifying only possible if one level is present.", 
          fixed = FALSE)
  })
  where 27: eval(code, test_env)
  where 28: eval(code, test_env)
  where 29: 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 30: doTryCatch(return(expr), name, parentenv, handler)
  where 31: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 32: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 33: doTryCatch(return(expr), name, parentenv, handler)
  where 34: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 35: tryCatchList(expr, classes, parentenv, handlers)
  where 36: 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 37: test_code(NULL, exprs, env)
  where 38: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 39: force(code)
  where 40: doWithOneRestart(return(expr), restart)
  where 41: withOneRestart(expr, restarts[[1L]])
  where 42: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 43: 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 44: FUN(X[[i]], ...)
  where 45: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 46: force(code)
  where 47: doWithOneRestart(return(expr), restart)
  where 48: withOneRestart(expr, restarts[[1L]])
  where 49: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 50: 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 51: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 52: 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 53: 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 54: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 13. Error: calculate_correlation returns warnings (@test-calculate_correlatio
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::calculate_lsm(...)
    2. landscapemetrics:::calculate_lsm.RasterStack(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::calculate_lsm_internal(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
    9. base::tryCatch(...)
   10. base:::tryCatchList(expr, classes, parentenv, handlers)
   11. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   12. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 
  1L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 
  2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 3L, 3L, 
  3L, 2L, 3L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3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 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 1L, 1L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 1L, 1L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 
  1L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 
  2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 1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 1L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 1L, 1L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 1L, 1L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, what = "lsm_p_area", verbose = FALSE)
  where 13 at testthat/test-calculate_correlation.R#43: calculate_lsm(landscape, what = "lsm_p_area", verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 25 at testthat/test-calculate_correlation.R#41: test_that("calculate_correlation returns error of only one metric is present", 
      {
          metrics <- calculate_lsm(landscape, what = "lsm_p_area", 
              verbose = FALSE)
          expect_error(calculate_correlation(metrics, method = "pearson"), 
              regexp = "Please provide input with more than one metric.", 
              fixed = FALSE)
          metrics <- calculate_lsm(landscape, what = "lsm_c_ca", 
              verbose = FALSE)
          expect_error(calculate_correlation(metrics, method = "pearson"), 
              regexp = "Please provide input with more than one metric.", 
              fixed = FALSE)
      })
  where 26: eval(code, test_env)
  where 27: eval(code, test_env)
  where 28: 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 29: doTryCatch(return(expr), name, parentenv, handler)
  where 30: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 31: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 32: doTryCatch(return(expr), name, parentenv, handler)
  where 33: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 34: tryCatchList(expr, classes, parentenv, handlers)
  where 35: 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 36: test_code(NULL, exprs, env)
  where 37: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 38: force(code)
  where 39: doWithOneRestart(return(expr), restart)
  where 40: withOneRestart(expr, restarts[[1L]])
  where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 42: 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 43: FUN(X[[i]], ...)
  where 44: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 45: force(code)
  where 46: doWithOneRestart(return(expr), restart)
  where 47: withOneRestart(expr, restarts[[1L]])
  where 48: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 49: 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 50: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 51: 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 52: 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 53: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 14. Error: calculate_correlation returns error of only one metric is present 
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::calculate_lsm(...)
    2. landscapemetrics:::calculate_lsm.RasterLayer(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. base::lapply(...)
    7. landscapemetrics:::FUN(X[[i]], ...)
    8. base::tryCatch(...)
    9. base:::tryCatchList(expr, classes, parentenv, handlers)
   10. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   11. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: (function (landscape, directions, resolution = NULL) 
  {
      area_patch <- lsm_p_area_calc(landscape, directions = directions, 
          resolution = resolution)
      area_cv <- raster::cv(area_patch$value)
      tibble::tibble(level = "landscape", class = as.integer(NA), 
          id = as.integer(NA), metric = "area_cv", value = as.double(area_cv))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L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, 2L, 1L, 1L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
  where 3: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 4: doTryCatch(return(expr), name, parentenv, handler)
  where 5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 6: tryCatchList(expr, classes, parentenv, handlers)
  where 7: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 8: FUN(X[[i]], ...)
  where 9: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 10: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 13: calculate_lsm.RasterLayer(landscape, level = "landscape", type = "area and edge metric", 
      verbose = FALSE)
  where 14 at testthat/test-calculate_correlation.R#62: calculate_lsm(landscape, level = "landscape", type = "area and edge metric", 
      verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 26 at testthat/test-calculate_correlation.R#60: test_that("calculate_correlation returns error of only one layer is present on landscape level", 
      {
          metrics <- calculate_lsm(landscape, level = "landscape", 
              type = "area and edge metric", verbose = FALSE)
          expect_error(calculate_correlation(metrics, method = "pearson"), 
              regexp = "Correlation on landscape level only possible for several landscapes.", 
              fixed = FALSE)
      })
  where 27: eval(code, test_env)
  where 28: eval(code, test_env)
  where 29: 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 30: doTryCatch(return(expr), name, parentenv, handler)
  where 31: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 32: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 33: doTryCatch(return(expr), name, parentenv, handler)
  where 34: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 35: tryCatchList(expr, classes, parentenv, handlers)
  where 36: 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 37: test_code(NULL, exprs, env)
  where 38: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 39: force(code)
  where 40: doWithOneRestart(return(expr), restart)
  where 41: withOneRestart(expr, restarts[[1L]])
  where 42: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 43: 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 44: FUN(X[[i]], ...)
  where 45: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 46: force(code)
  where 47: doWithOneRestart(return(expr), restart)
  where 48: withOneRestart(expr, restarts[[1L]])
  where 49: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 50: 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 51: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 52: 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 53: 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 54: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 15. Error: calculate_correlation returns error of only one layer is present o
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::calculate_lsm(...)
    2. landscapemetrics:::calculate_lsm.RasterLayer(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. base::lapply(...)
    7. landscapemetrics:::FUN(X[[i]], ...)
    8. base::tryCatch(...)
    9. base:::tryCatchList(expr, classes, parentenv, handlers)
   10. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   11. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L,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 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L,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 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, what = metrics_list, directions = directions, 
      verbose = verbose, progress = progress, ...)
  where 13: calculate_lsm(landscape, what = metrics_list, directions = directions, 
      verbose = verbose, progress = progress, ...)
  where 14: FUN(X[[i]], ...)
  where 15: lapply(raster::as.list(landscape), FUN = extract_lsm_internal, 
      y = y, extract_id = extract_id, metric = metric, name = name, 
      type = type, what = what, directions = directions, progress = progress, 
      verbose = verbose, ...)
  where 16: extract_lsm.RasterLayer(landscape, y = sample_points, what = "lsm_p_area", 
      type = "aggregation metric", verbose = FALSE)
  where 17 at testthat/test-extract-lsm.R#16: extract_lsm(landscape, y = sample_points, what = "lsm_p_area", 
      type = "aggregation metric", verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 29 at testthat/test-extract-lsm.R#14: test_that("extract_lsm returns correct metrics", {
      patch_area <- extract_lsm(landscape, y = sample_points, what = "lsm_p_area", 
          type = "aggregation metric", verbose = FALSE)
      expect_true(all(patch_area$metric == "area"))
      patch_core <- extract_lsm(landscape, y = sample_points, type = "core area metric", 
          full_name = TRUE, verbose = FALSE)
      expect_true(all(patch_core$type == "core area metric"))
      patch_all <- extract_lsm(landscape, y = sample_points, verbose = FALSE)
      expect_true(all(unique(patch_all$metric) == list_lsm(level = "patch")[, 
          1]))
  })
  where 30: eval(code, test_env)
  where 31: eval(code, test_env)
  where 32: 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 33: doTryCatch(return(expr), name, parentenv, handler)
  where 34: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 35: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 36: doTryCatch(return(expr), name, parentenv, handler)
  where 37: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 38: tryCatchList(expr, classes, parentenv, handlers)
  where 39: 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 40: test_code(NULL, exprs, env)
  where 41: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 42: force(code)
  where 43: doWithOneRestart(return(expr), restart)
  where 44: withOneRestart(expr, restarts[[1L]])
  where 45: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 46: 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 47: FUN(X[[i]], ...)
  where 48: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 49: force(code)
  where 50: doWithOneRestart(return(expr), restart)
  where 51: withOneRestart(expr, restarts[[1L]])
  where 52: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 53: 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 54: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 55: 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 56: 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 57: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 16. Error: extract_lsm returns correct metrics (@test-extract-lsm.R#16)  ----
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::extract_lsm(...)
    2. landscapemetrics:::extract_lsm.RasterLayer(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. landscapemetrics:::calculate_lsm.RasterLayer(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. base::lapply(...)
   11. landscapemetrics:::FUN(X[[i]], ...)
   12. base::tryCatch(...)
   13. base:::tryCatchList(expr, classes, parentenv, handlers)
   14. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   15. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3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 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3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L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, what = metrics_list, directions = directions, 
      verbose = verbose, progress = progress, ...)
  where 13: calculate_lsm(landscape, what = metrics_list, directions = directions, 
      verbose = verbose, progress = progress, ...)
  where 14: FUN(X[[i]], ...)
  where 15: lapply(raster::as.list(landscape), FUN = extract_lsm_internal, 
      y = y, extract_id = extract_id, metric = metric, name = name, 
      type = type, what = what, directions = directions, progress = progress, 
      verbose = verbose, ...)
  where 16: extract_lsm.RasterLayer(landscape, y = sample_lines, what = "lsm_p_area", 
      verbose = FALSE)
  where 17 at testthat/test-extract-lsm.R#41: extract_lsm(landscape, y = sample_lines, what = "lsm_p_area", 
      verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 29 at testthat/test-extract-lsm.R#39: test_that("extract_lsm works for lines", {
      result <- extract_lsm(landscape, y = sample_lines, what = "lsm_p_area", 
          verbose = FALSE)
      expect_is(result, "tbl_df")
      expect_true(all(result$metric %in% "area"))
  })
  where 30: eval(code, test_env)
  where 31: eval(code, test_env)
  where 32: 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 33: doTryCatch(return(expr), name, parentenv, handler)
  where 34: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 35: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 36: doTryCatch(return(expr), name, parentenv, handler)
  where 37: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 38: tryCatchList(expr, classes, parentenv, handlers)
  where 39: 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 40: test_code(NULL, exprs, env)
  where 41: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 42: force(code)
  where 43: doWithOneRestart(return(expr), restart)
  where 44: withOneRestart(expr, restarts[[1L]])
  where 45: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 46: 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 47: FUN(X[[i]], ...)
  where 48: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 49: force(code)
  where 50: doWithOneRestart(return(expr), restart)
  where 51: withOneRestart(expr, restarts[[1L]])
  where 52: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 53: 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 54: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 55: 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 56: 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 57: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 17. Error: extract_lsm works for lines (@test-extract-lsm.R#41)  ------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::extract_lsm(...)
    2. landscapemetrics:::extract_lsm.RasterLayer(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. landscapemetrics:::calculate_lsm.RasterLayer(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. base::lapply(...)
   11. landscapemetrics:::FUN(X[[i]], ...)
   12. base::tryCatch(...)
   13. base:::tryCatchList(expr, classes, parentenv, handlers)
   14. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   15. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, consider_boundary, edge_depth, 
      resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      classes <- get_unique_values(landscape)[[1]]
      core <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          class_edge <- get_boundaries(landscape_labeled, directions = 4, 
              consider_boundary = consider_boundary)[[1]]
          cells_edge_patch <- table(landscape_labeled[class_edge == 
              1])
          if (edge_depth > 1) {
              for (i in seq_len(edge_depth - 1)) {
                  class_edge[class_edge == 1] <- NA
                  class_edge <- get_boundaries(class_edge, directions = 4, 
                    consider_boundary = consider_boundary)[[1]]
                  cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                    1], nbins = length(cells_edge_patch))
              }
          }
          cells_patch <- table(landscape_labeled)
          if (dim(cells_edge_patch) == 0) {
              cells_edge_patch <- 0
          }
          core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
          tibble::tibble(class = patches_class, value = core_area)
      }))
      tibble::tibble(level = "patch", class = as.integer(core$class), 
          id = as.integer(seq_len(nrow(core))), metric = "core", 
          value = as.double(core$value))
  })(landscape = c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 2L, 2L, 
  2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 1L, 1L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, consider_boundary = FALSE, 
      edge_depth = 100, resolution = c(1, 1))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, consider_boundary, edge_depth, 
      resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      classes <- get_unique_values(landscape)[[1]]
      core <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          class_edge <- get_boundaries(landscape_labeled, directions = 4, 
              consider_boundary = consider_boundary)[[1]]
          cells_edge_patch <- table(landscape_labeled[class_edge == 
              1])
          if (edge_depth > 1) {
              for (i in seq_len(edge_depth - 1)) {
                  class_edge[class_edge == 1] <- NA
                  class_edge <- get_boundaries(class_edge, directions = 4, 
                    consider_boundary = consider_boundary)[[1]]
                  cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                    1], nbins = length(cells_edge_patch))
              }
          }
          cells_patch <- table(landscape_labeled)
          if (dim(cells_edge_patch) == 0) {
              cells_edge_patch <- 0
          }
          core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
          tibble::tibble(class = patches_class, value = core_area)
      }))
      tibble::tibble(level = "patch", class = as.integer(core$class), 
          id = as.integer(seq_len(nrow(core))), metric = "core", 
          value = as.double(core$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 
  1L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2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 2L), directions = 8, consider_boundary = FALSE, 
      edge_depth = 100, resolution = c(1, 1))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, what = metrics_list, directions = directions, 
      verbose = verbose, progress = progress, ...)
  where 13: calculate_lsm(landscape, what = metrics_list, directions = directions, 
      verbose = verbose, progress = progress, ...)
  where 14: FUN(X[[i]], ...)
  where 15: lapply(raster::as.list(landscape), FUN = extract_lsm_internal, 
      y = y, extract_id = extract_id, metric = metric, name = name, 
      type = type, what = what, directions = directions, progress = progress, 
      verbose = verbose, ...)
  where 16: extract_lsm.RasterLayer(landscape, y = sample_points, what = "lsm_p_core", 
      edge_depth = 100, verbose = FALSE)
  where 17 at testthat/test-extract-lsm.R#52: extract_lsm(landscape, y = sample_points, what = "lsm_p_core", 
      edge_depth = 100, verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 29 at testthat/test-extract-lsm.R#50: test_that("extract_lsm forwards arguments to calculate_lsm", 
      {
          result <- extract_lsm(landscape, y = sample_points, what = "lsm_p_core", 
              edge_depth = 100, verbose = FALSE)
          expect_true(all(result$value == 0))
      })
  where 30: eval(code, test_env)
  where 31: eval(code, test_env)
  where 32: 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 33: doTryCatch(return(expr), name, parentenv, handler)
  where 34: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 35: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 36: doTryCatch(return(expr), name, parentenv, handler)
  where 37: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 38: tryCatchList(expr, classes, parentenv, handlers)
  where 39: 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 40: test_code(NULL, exprs, env)
  where 41: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 42: force(code)
  where 43: doWithOneRestart(return(expr), restart)
  where 44: withOneRestart(expr, restarts[[1L]])
  where 45: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 46: 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 47: FUN(X[[i]], ...)
  where 48: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 49: force(code)
  where 50: doWithOneRestart(return(expr), restart)
  where 51: withOneRestart(expr, restarts[[1L]])
  where 52: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 53: 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 54: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 55: 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 56: 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 57: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, consider_boundary, edge_depth, 
      resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      classes <- get_unique_values(landscape)[[1]]
      core <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          class_edge <- get_boundaries(landscape_labeled, directions = 4, 
              consider_boundary = consider_boundary)[[1]]
          cells_edge_patch <- table(landscape_labeled[class_edge == 
              1])
          if (edge_depth > 1) {
              for (i in seq_len(edge_depth - 1)) {
                  class_edge[class_edge == 1] <- NA
                  class_edge <- get_boundaries(class_edge, directions = 4, 
                    consider_boundary = consider_boundary)[[1]]
                  cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                    1], nbins = length(cells_edge_patch))
              }
          }
          cells_patch <- table(landscape_labeled)
          if (dim(cells_edge_patch) == 0) {
              cells_edge_patch <- 0
          }
          core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
          tibble::tibble(class = patches_class, value = core_area)
      }))
      tibble::tibble(level = "patch", class = as.integer(core$class), 
          id = as.integer(seq_len(nrow(core))), metric = "core", 
          value = as.double(core$value))
  }
  <bytecode: 0x823c7e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_core_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 18. Error: extract_lsm forwards arguments to calculate_lsm (@test-extract-lsm
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::extract_lsm(...)
    2. landscapemetrics:::extract_lsm.RasterLayer(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. landscapemetrics:::calculate_lsm.RasterLayer(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. base::lapply(...)
   11. landscapemetrics:::FUN(X[[i]], ...)
   12. base::tryCatch(...)
   13. base:::tryCatchList(expr, classes, parentenv, handlers)
   14. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   15. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2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L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L,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L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, what = metrics_list, directions = directions, 
      verbose = verbose, progress = progress, ...)
  where 13: calculate_lsm(landscape, what = metrics_list, directions = directions, 
      verbose = verbose, progress = progress, ...)
  where 14: FUN(X[[i]], ...)
  where 15: lapply(raster::as.list(landscape), FUN = extract_lsm_internal, 
      y = y, extract_id = extract_id, metric = metric, name = name, 
      type = type, what = what, directions = directions, progress = progress, 
      verbose = verbose, ...)
  where 16: extract_lsm.RasterLayer(landscape, y = sample_points, extract_id = c(5, 
      25, 15), what = "lsm_p_area", verbose = FALSE)
  where 17 at testthat/test-extract-lsm.R#63: extract_lsm(landscape, y = sample_points, extract_id = c(5, 25, 
      15), what = "lsm_p_area", verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 29 at testthat/test-extract-lsm.R#61: test_that("extract_lsm uses extract_ids", {
      result <- extract_lsm(landscape, y = sample_points, extract_id = c(5, 
          25, 15), what = "lsm_p_area", verbose = FALSE)
      expect_equal(result$extract_id, expected = c(5, 15, 25))
      result_wrong_id <- extract_lsm(landscape, y = sample_points, 
          extract_id = c(1, 5, 25, 15), what = "lsm_p_area", verbose = FALSE)
      expect_equal(result_wrong_id$extract_id, expected = 1:3)
  })
  where 30: eval(code, test_env)
  where 31: eval(code, test_env)
  where 32: 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 33: doTryCatch(return(expr), name, parentenv, handler)
  where 34: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 35: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 36: doTryCatch(return(expr), name, parentenv, handler)
  where 37: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 38: tryCatchList(expr, classes, parentenv, handlers)
  where 39: 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 40: test_code(NULL, exprs, env)
  where 41: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 42: force(code)
  where 43: doWithOneRestart(return(expr), restart)
  where 44: withOneRestart(expr, restarts[[1L]])
  where 45: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 46: 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 47: FUN(X[[i]], ...)
  where 48: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 49: force(code)
  where 50: doWithOneRestart(return(expr), restart)
  where 51: withOneRestart(expr, restarts[[1L]])
  where 52: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 53: 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 54: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 55: 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 56: 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 57: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 19. Error: extract_lsm uses extract_ids (@test-extract-lsm.R#63)  -----------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::extract_lsm(...)
    2. landscapemetrics:::extract_lsm.RasterLayer(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. landscapemetrics:::calculate_lsm.RasterLayer(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. base::lapply(...)
   11. landscapemetrics:::FUN(X[[i]], ...)
   12. base::tryCatch(...)
   13. base:::tryCatchList(expr, classes, parentenv, handlers)
   14. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   15. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L,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 1L, 1L, 1L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3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 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, what = metrics_list, directions = directions, 
      verbose = verbose, progress = progress, ...)
  where 13: calculate_lsm(landscape, what = metrics_list, directions = directions, 
      verbose = verbose, progress = progress, ...)
  where 14: extract_lsm_internal(landscape = landscape[[x]], y = y, extract_id = extract_id, 
      metric = metric, name = name, type = type, what = what, directions = directions, 
      progress = FALSE, verbose = verbose, ...)
  where 15: FUN(X[[i]], ...)
  where 16: lapply(X = seq_along(landscape), FUN = function(x) {
      if (progress) {
          message("\r> Progress nlayers: ", x, "/", length(landscape), 
              appendLF = FALSE)
      }
      extract_lsm_internal(landscape = landscape[[x]], y = y, extract_id = extract_id, 
          metric = metric, name = name, type = type, what = what, 
          directions = directions, progress = FALSE, verbose = verbose, 
          ...)
  })
  where 17: extract_lsm.RasterStack(landscape = landscape_stack, y = sample_points, 
      what = "lsm_p_area", verbose = FALSE)
  where 18 at testthat/test-extract-lsm.R#82: extract_lsm(landscape = landscape_stack, y = sample_points, what = "lsm_p_area", 
      verbose = FALSE)
  where 19: eval(code, test_env)
  where 20: eval(code, test_env)
  where 21: 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 22: doTryCatch(return(expr), name, parentenv, handler)
  where 23: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 24: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 25: doTryCatch(return(expr), name, parentenv, handler)
  where 26: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 27: tryCatchList(expr, classes, parentenv, handlers)
  where 28: 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 29: test_code(desc, code, env = parent.frame())
  where 30 at testthat/test-extract-lsm.R#80: test_that("extract_lsm works for all data types", {
      result_stack <- extract_lsm(landscape = landscape_stack, 
          y = sample_points, what = "lsm_p_area", verbose = FALSE)
      result_brick <- extract_lsm(landscape = landscape_brick, 
          y = sample_points, what = "lsm_p_area", verbose = FALSE)
      result_list <- extract_lsm(landscape = landscape_list, y = sample_points, 
          what = "lsm_p_area", verbose = FALSE)
      expect_is(result_stack, "tbl_df")
      expect_is(result_brick, "tbl_df")
      expect_is(result_list, "tbl_df")
      expect_equal(object = result_stack$layer, expected = c(1, 
          1, 1, 2, 2, 2))
      expect_equal(object = result_brick$layer, expected = c(1, 
          1, 1, 2, 2, 2))
      expect_equal(object = result_list$layer, expected = c(1, 
          1, 1, 2, 2, 2))
      expect_true("area" %in% result_stack$metric)
      expect_true("area" %in% result_brick$metric)
      expect_true("area" %in% result_list$metric)
  })
  where 31: eval(code, test_env)
  where 32: eval(code, test_env)
  where 33: 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 34: doTryCatch(return(expr), name, parentenv, handler)
  where 35: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 36: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 37: doTryCatch(return(expr), name, parentenv, handler)
  where 38: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 39: tryCatchList(expr, classes, parentenv, handlers)
  where 40: 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 41: test_code(NULL, exprs, env)
  where 42: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 43: force(code)
  where 44: doWithOneRestart(return(expr), restart)
  where 45: withOneRestart(expr, restarts[[1L]])
  where 46: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 47: 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 48: FUN(X[[i]], ...)
  where 49: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 50: force(code)
  where 51: doWithOneRestart(return(expr), restart)
  where 52: withOneRestart(expr, restarts[[1L]])
  where 53: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 54: 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 55: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 56: 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 57: 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 58: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 20. Error: extract_lsm works for all data types (@test-extract-lsm.R#82)  ---
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::extract_lsm(...)
    2. landscapemetrics:::extract_lsm.RasterStack(...)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::extract_lsm_internal(...)
    7. landscapemetrics:::calculate_lsm.RasterLayer(...)
    8. base::lapply(...)
    9. landscapemetrics:::FUN(X[[i]], ...)
   11. base::lapply(...)
   12. landscapemetrics:::FUN(X[[i]], ...)
   13. base::tryCatch(...)
   14. base:::tryCatchList(expr, classes, parentenv, handlers)
   15. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   16. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 
  1L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 
  2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3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 3L, 3L, 2L, 2L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 1L, 1L, 1L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 1L, 1L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 
  2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 1L, 1L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 
  1L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 
  2L, 3L, 3L, 3L, 3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))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, what = metrics_list, directions = directions, 
      verbose = verbose, progress = progress, ...)
  where 13: calculate_lsm(landscape, what = metrics_list, directions = directions, 
      verbose = verbose, progress = progress, ...)
  where 14: FUN(X[[i]], ...)
  where 15: lapply(raster::as.list(landscape), FUN = extract_lsm_internal, 
      y = y, extract_id = extract_id, metric = metric, name = name, 
      type = type, what = what, directions = directions, progress = progress, 
      verbose = verbose, ...)
  where 16: extract_lsm.RasterLayer(landscape, y = sample_points, extract_id = c(15, 
      25, 5, 1), what = "lsm_p_area")
  where 17: extract_lsm(landscape, y = sample_points, extract_id = c(15, 
      25, 5, 1), what = "lsm_p_area")
  where 18: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
  where 19: withCallingHandlers(code, warning = function(condition) {
      out$push(condition)
      maybe_restart("muffleWarning")
  })
  where 20: .capture(act$val <- eval_bare(quo_get_expr(.quo), quo_get_env(.quo)), 
      ...)
  where 21: quasi_capture(enquo(object), label, capture_warnings)
  where 22 at testthat/test-extract-lsm.R#115: expect_warning(extract_lsm(landscape, y = sample_points, extract_id = c(15, 
      25, 5, 1), what = "lsm_p_area"), regexp = "Length of extract_id is not identical to length of y. Using 1...n as extract_id.", 
      fixed = TRUE)
  where 23: eval(code, test_env)
  where 24: eval(code, test_env)
  where 25: 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 26: doTryCatch(return(expr), name, parentenv, handler)
  where 27: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 28: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 29: doTryCatch(return(expr), name, parentenv, handler)
  where 30: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 31: tryCatchList(expr, classes, parentenv, handlers)
  where 32: 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 33: test_code(desc, code, env = parent.frame())
  where 34 at testthat/test-extract-lsm.R#113: test_that("extract_lsm returns warnings", {
      expect_warning(extract_lsm(landscape, y = sample_points, 
          extract_id = c(15, 25, 5, 1), what = "lsm_p_area"), regexp = "Length of extract_id is not identical to length of y. Using 1...n as extract_id.", 
          fixed = TRUE)
  })
  where 35: eval(code, test_env)
  where 36: eval(code, test_env)
  where 37: 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 38: doTryCatch(return(expr), name, parentenv, handler)
  where 39: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 40: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 41: doTryCatch(return(expr), name, parentenv, handler)
  where 42: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 43: tryCatchList(expr, classes, parentenv, handlers)
  where 44: 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 45: test_code(NULL, exprs, env)
  where 46: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 47: force(code)
  where 48: doWithOneRestart(return(expr), restart)
  where 49: withOneRestart(expr, restarts[[1L]])
  where 50: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 51: 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 52: FUN(X[[i]], ...)
  where 53: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 54: force(code)
  where 55: doWithOneRestart(return(expr), restart)
  where 56: withOneRestart(expr, restarts[[1L]])
  where 57: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 58: 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 59: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 60: 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 61: 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 62: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 21. Error: extract_lsm returns warnings (@test-extract-lsm.R#115)  ----------
  the condition has length > 1
  Backtrace:
    1. testthat::expect_warning(...)
    7. landscapemetrics:::extract_lsm.RasterLayer(...)
    8. base::lapply(...)
    9. landscapemetrics:::FUN(X[[i]], ...)
   11. landscapemetrics:::calculate_lsm.RasterLayer(...)
   12. base::lapply(...)
   13. landscapemetrics:::FUN(X[[i]], ...)
   15. base::lapply(...)
   16. landscapemetrics:::FUN(X[[i]], ...)
   17. base::tryCatch(...)
   18. base:::tryCatchList(expr, classes, parentenv, handlers)
   19. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
   20. value[[3L]](cond)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(raster::as.matrix(x), directions = directions, 
      consider_boundary = consider_boundary, as_NA = as_NA)
  where 6: FUN(X[[i]], ...)
  where 7: lapply(raster::as.list(landscape), function(x) {
      result_temp <- get_boundaries.matrix(raster::as.matrix(x), 
          directions = directions, consider_boundary = consider_boundary, 
          as_NA = as_NA)[[1]]
      if (return_raster) {
          result_temp <- matrix_to_raster(matrix = result_temp, 
              landscape = landscape)
      }
      return(result_temp)
  })
  where 8: get_boundaries.RasterLayer(landscape)
  where 9 at testthat/test-get-boundaries.R#5: get_boundaries(landscape)
  where 10: eval(code, test_env)
  where 11: eval(code, test_env)
  where 12: 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 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 15: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 16: doTryCatch(return(expr), name, parentenv, handler)
  where 17: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 18: tryCatchList(expr, classes, parentenv, handlers)
  where 19: 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 20: test_code(desc, code, env = parent.frame())
  where 21 at testthat/test-get-boundaries.R#3: test_that("get_boundaries works for RasterLayer", {
      result <- get_boundaries(landscape)[[1]]
      expect_is(result, "RasterLayer")
      expect_true(raster::extent(landscape) == raster::extent(result))
      expect_true(all(get_unique_values(result)[[1]] == c(0, 1)))
  })
  where 22: eval(code, test_env)
  where 23: eval(code, test_env)
  where 24: 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 25: doTryCatch(return(expr), name, parentenv, handler)
  where 26: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 27: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 28: doTryCatch(return(expr), name, parentenv, handler)
  where 29: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 30: tryCatchList(expr, classes, parentenv, handlers)
  where 31: 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 32: test_code(NULL, exprs, env)
  where 33: source_file(path, new.env(parent = env), chdir = TRUE, 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 = 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 39: FUN(X[[i]], ...)
  where 40: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 41: force(code)
  where 42: doWithOneRestart(return(expr), restart)
  where 43: withOneRestart(expr, restarts[[1L]])
  where 44: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 45: 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 46: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 47: 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 48: 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 49: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 22. Error: get_boundaries works for RasterLayer (@test-get-boundaries.R#5)  -
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::get_boundaries(landscape)
   2. landscapemetrics:::get_boundaries.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::get_boundaries.matrix(...)
   7. landscapemetrics:::pad_raster.matrix(...)
   8. base::lapply(...)
   9. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(raster::as.matrix(x), directions = directions, 
      consider_boundary = consider_boundary, as_NA = as_NA)
  where 6: FUN(X[[i]], ...)
  where 7: lapply(raster::as.list(landscape), function(x) {
      result_temp <- get_boundaries.matrix(raster::as.matrix(x), 
          directions = directions, consider_boundary = consider_boundary, 
          as_NA = as_NA)[[1]]
      if (return_raster) {
          result_temp <- matrix_to_raster(matrix = result_temp, 
              landscape = landscape)
      }
      return(result_temp)
  })
  where 8: get_boundaries.RasterLayer(landscape = landscape, return_raster = FALSE)
  where 9 at testthat/test-get-boundaries.R#14: get_boundaries(landscape = landscape, return_raster = FALSE)
  where 10: eval(code, test_env)
  where 11: eval(code, test_env)
  where 12: 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 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 15: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 16: doTryCatch(return(expr), name, parentenv, handler)
  where 17: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 18: tryCatchList(expr, classes, parentenv, handlers)
  where 19: 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 20: test_code(desc, code, env = parent.frame())
  where 21 at testthat/test-get-boundaries.R#12: test_that("get_boundaries works for matrix", {
      result <- get_boundaries(landscape = landscape, return_raster = FALSE)[[1]]
      expect_is(result, "matrix")
      expect_equal(prod(dim(result)), expected = raster::ncell(landscape))
      expect_equal(get_unique_values(result)[[1]], expected = c(0, 
          1))
  })
  where 22: eval(code, test_env)
  where 23: eval(code, test_env)
  where 24: 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 25: doTryCatch(return(expr), name, parentenv, handler)
  where 26: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 27: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 28: doTryCatch(return(expr), name, parentenv, handler)
  where 29: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 30: tryCatchList(expr, classes, parentenv, handlers)
  where 31: 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 32: test_code(NULL, exprs, env)
  where 33: source_file(path, new.env(parent = env), chdir = TRUE, 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 = 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 39: FUN(X[[i]], ...)
  where 40: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 41: force(code)
  where 42: doWithOneRestart(return(expr), restart)
  where 43: withOneRestart(expr, restarts[[1L]])
  where 44: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 45: 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 46: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 47: 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 48: 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 49: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 23. Error: get_boundaries works for matrix (@test-get-boundaries.R#14)  -----
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::get_boundaries(landscape = landscape, return_raster = FALSE)
   2. landscapemetrics:::get_boundaries.RasterLayer(...)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::get_boundaries.matrix(...)
   7. landscapemetrics:::pad_raster.matrix(...)
   8. base::lapply(...)
   9. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(raster::as.matrix(x), directions = directions, 
      consider_boundary = consider_boundary, as_NA = as_NA)
  where 6: FUN(X[[i]], ...)
  where 7: lapply(X = raster::as.list(landscape), function(x) {
      result_temp <- get_boundaries.matrix(raster::as.matrix(x), 
          directions = directions, consider_boundary = consider_boundary, 
          as_NA = as_NA)[[1]]
      if (return_raster) {
          result_temp <- matrix_to_raster(matrix = result_temp, 
              landscape = x)
      }
      return(result_temp)
  })
  where 8: get_boundaries.RasterStack(landscape_stack)
  where 9 at testthat/test-get-boundaries.R#26: get_boundaries(landscape_stack)
  where 10: eval(code, test_env)
  where 11: eval(code, test_env)
  where 12: 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 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 15: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 16: doTryCatch(return(expr), name, parentenv, handler)
  where 17: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 18: tryCatchList(expr, classes, parentenv, handlers)
  where 19: 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 20: test_code(desc, code, env = parent.frame())
  where 21 at testthat/test-get-boundaries.R#24: test_that("get_boundaries works for all other data types", {
      result_stack <- get_boundaries(landscape_stack)
      result_brick <- get_boundaries(landscape_brick)
      result_list <- get_boundaries(landscape_list)
      expect_is(result_stack, "list")
      expect_is(result_brick, "list")
      expect_is(result_list, "list")
  })
  where 22: eval(code, test_env)
  where 23: eval(code, test_env)
  where 24: 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 25: doTryCatch(return(expr), name, parentenv, handler)
  where 26: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 27: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 28: doTryCatch(return(expr), name, parentenv, handler)
  where 29: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 30: tryCatchList(expr, classes, parentenv, handlers)
  where 31: 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 32: test_code(NULL, exprs, env)
  where 33: source_file(path, new.env(parent = env), chdir = TRUE, 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 = 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 39: FUN(X[[i]], ...)
  where 40: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 41: force(code)
  where 42: doWithOneRestart(return(expr), restart)
  where 43: withOneRestart(expr, restarts[[1L]])
  where 44: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 45: 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 46: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 47: 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 48: 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 49: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 24. Error: get_boundaries works for all other data types (@test-get-boundarie
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::get_boundaries(landscape_stack)
   2. landscapemetrics:::get_boundaries.RasterStack(landscape_stack)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::get_boundaries.matrix(...)
   7. landscapemetrics:::pad_raster.matrix(...)
   8. base::lapply(...)
   9. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(raster::as.matrix(x), directions = directions, 
      consider_boundary = consider_boundary, as_NA = as_NA)
  where 6: FUN(X[[i]], ...)
  where 7: lapply(raster::as.list(landscape), function(x) {
      result_temp <- get_boundaries.matrix(raster::as.matrix(x), 
          directions = directions, consider_boundary = consider_boundary, 
          as_NA = as_NA)[[1]]
      if (return_raster) {
          result_temp <- matrix_to_raster(matrix = result_temp, 
              landscape = landscape)
      }
      return(result_temp)
  })
  where 8: get_boundaries.RasterLayer(landscape, as_NA = TRUE)
  where 9 at testthat/test-get-boundaries.R#37: get_boundaries(landscape, as_NA = TRUE)
  where 10: eval(code, test_env)
  where 11: eval(code, test_env)
  where 12: 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 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 15: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 16: doTryCatch(return(expr), name, parentenv, handler)
  where 17: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 18: tryCatchList(expr, classes, parentenv, handlers)
  where 19: 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 20: test_code(desc, code, env = parent.frame())
  where 21 at testthat/test-get-boundaries.R#35: test_that("get_boundaries returns only 1 and NA", {
      result <- get_boundaries(landscape, as_NA = TRUE)[[1]]
      expect_equal(get_unique_values(result)[[1]], expected = 1)
  })
  where 22: eval(code, test_env)
  where 23: eval(code, test_env)
  where 24: 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 25: doTryCatch(return(expr), name, parentenv, handler)
  where 26: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 27: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 28: doTryCatch(return(expr), name, parentenv, handler)
  where 29: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 30: tryCatchList(expr, classes, parentenv, handlers)
  where 31: 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 32: test_code(NULL, exprs, env)
  where 33: source_file(path, new.env(parent = env), chdir = TRUE, 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 = 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 39: FUN(X[[i]], ...)
  where 40: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 41: force(code)
  where 42: doWithOneRestart(return(expr), restart)
  where 43: withOneRestart(expr, restarts[[1L]])
  where 44: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 45: 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 46: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 47: 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 48: 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 49: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 25. Error: get_boundaries returns only 1 and NA (@test-get-boundaries.R#37)  
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::get_boundaries(landscape, as_NA = TRUE)
   2. landscapemetrics:::get_boundaries.RasterLayer(landscape, as_NA = TRUE)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::get_boundaries.matrix(...)
   7. landscapemetrics:::pad_raster.matrix(...)
   8. base::lapply(...)
   9. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(raster::as.matrix(x), directions = directions, 
      consider_boundary = consider_boundary, as_NA = as_NA)
  where 6: FUN(X[[i]], ...)
  where 7: lapply(raster::as.list(landscape), function(x) {
      result_temp <- get_boundaries.matrix(raster::as.matrix(x), 
          directions = directions, consider_boundary = consider_boundary, 
          as_NA = as_NA)[[1]]
      if (return_raster) {
          result_temp <- matrix_to_raster(matrix = result_temp, 
              landscape = landscape)
      }
      return(result_temp)
  })
  where 8: get_boundaries.RasterLayer(class_1, directions = 4)
  where 9 at testthat/test-get-boundaries.R#47: get_boundaries(class_1, directions = 4)
  where 10: eval(code, test_env)
  where 11: eval(code, test_env)
  where 12: 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 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 15: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 16: doTryCatch(return(expr), name, parentenv, handler)
  where 17: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 18: tryCatchList(expr, classes, parentenv, handlers)
  where 19: 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 20: test_code(desc, code, env = parent.frame())
  where 21 at testthat/test-get-boundaries.R#44: test_that("get_boundaries works for 8 directions", {
      class_1 <- get_patches(landscape, class = 1)[[1]]
      result4 <- get_boundaries(class_1, directions = 4)[[1]]
      result8 <- get_boundaries(class_1, directions = 8)[[1]]
      expect_true(min(raster::getValues(result8) - raster::getValues(result4), 
          na.rm = TRUE) >= 0)
  })
  where 22: eval(code, test_env)
  where 23: eval(code, test_env)
  where 24: 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 25: doTryCatch(return(expr), name, parentenv, handler)
  where 26: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 27: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 28: doTryCatch(return(expr), name, parentenv, handler)
  where 29: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 30: tryCatchList(expr, classes, parentenv, handlers)
  where 31: 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 32: test_code(NULL, exprs, env)
  where 33: source_file(path, new.env(parent = env), chdir = TRUE, 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 = 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 39: FUN(X[[i]], ...)
  where 40: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 41: force(code)
  where 42: doWithOneRestart(return(expr), restart)
  where 43: withOneRestart(expr, restarts[[1L]])
  where 44: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 45: 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 46: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 47: 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 48: 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 49: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 26. Error: get_boundaries works for 8 directions (@test-get-boundaries.R#47) 
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::get_boundaries(class_1, directions = 4)
   2. landscapemetrics:::get_boundaries.RasterLayer(class_1, directions = 4)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::get_boundaries.matrix(...)
   7. landscapemetrics:::pad_raster.matrix(...)
   8. base::lapply(...)
   9. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(current_element) == "RasterLayer") {
      return(get_unique_values.RasterLayer(current_element, simplify = TRUE, 
          verbose = verbose))
  } else if (class(current_element) %in% c("numeric", "double", 
      "integer")) {
      return(get_unique_values.numeric(current_element, simplify = TRUE, 
          verbose = verbose))
  } else if (class(current_element) == "matrix") {
      get_unique_values.matrix(current_element, simplify = TRUE, 
          verbose = verbose)
  } else {
      stop("List elements must be a RasterLayer, matrix or vector.")
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(x, FUN = function(current_element) {
      if (class(current_element) == "RasterLayer") {
          return(get_unique_values.RasterLayer(current_element, 
              simplify = TRUE, verbose = verbose))
      }
      else if (class(current_element) %in% c("numeric", "double", 
          "integer")) {
          return(get_unique_values.numeric(current_element, simplify = TRUE, 
              verbose = verbose))
      }
      else if (class(current_element) == "matrix") {
          get_unique_values.matrix(current_element, simplify = TRUE, 
              verbose = verbose)
      }
      else {
          stop("List elements must be a RasterLayer, matrix or vector.")
      }
  })
  where 3: get_unique_values.list(list_x)
  where 4: get_unique_values(list_x)
  where 5: eval_bare(expr, quo_get_env(quo))
  where 6: quasi_label(enquo(object), label, arg = "object")
  where 7 at testthat/test-get-unique-values.R#35: expect_is(get_unique_values(list_x), class = "list")
  where 8: eval(code, test_env)
  where 9: eval(code, test_env)
  where 10: 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 11: doTryCatch(return(expr), name, parentenv, handler)
  where 12: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 13: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 14: doTryCatch(return(expr), name, parentenv, handler)
  where 15: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 16: tryCatchList(expr, classes, parentenv, handlers)
  where 17: 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 18: test_code(desc, code, env = parent.frame())
  where 19 at testthat/test-get-unique-values.R#33: test_that("get_unique_values works for list", {
      expect_is(get_unique_values(list_x), class = "list")
      expect_length(get_unique_values(list_x), n = 3)
      expect_warning(get_unique_values(list_x, simplify = TRUE), 
          regexp = "Not able to simply list with more than 1 element.", 
          fixed = TRUE)
  })
  where 20: eval(code, test_env)
  where 21: eval(code, test_env)
  where 22: 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 23: doTryCatch(return(expr), name, parentenv, handler)
  where 24: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 25: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 26: doTryCatch(return(expr), name, parentenv, handler)
  where 27: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 28: tryCatchList(expr, classes, parentenv, handlers)
  where 29: 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 30: test_code(NULL, exprs, env)
  where 31: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 32: force(code)
  where 33: doWithOneRestart(return(expr), restart)
  where 34: withOneRestart(expr, restarts[[1L]])
  where 35: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 36: 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 37: FUN(X[[i]], ...)
  where 38: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 39: force(code)
  where 40: doWithOneRestart(return(expr), restart)
  where 41: withOneRestart(expr, restarts[[1L]])
  where 42: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 43: 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 44: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 45: 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 46: 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 47: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (current_element) 
  {
      if (class(current_element) == "RasterLayer") {
          return(get_unique_values.RasterLayer(current_element, 
              simplify = TRUE, verbose = verbose))
      }
      else if (class(current_element) %in% c("numeric", "double", 
          "integer")) {
          return(get_unique_values.numeric(current_element, simplify = TRUE, 
              verbose = verbose))
      }
      else if (class(current_element) == "matrix") {
          get_unique_values.matrix(current_element, simplify = TRUE, 
              verbose = verbose)
      }
      else {
          stop("List elements must be a RasterLayer, matrix or vector.")
      }
  }
  <bytecode: 0x8575bc0>
  <environment: 0x1c159198>
   --- function search by body ---
   ----------- END OF FAILURE REPORT -------------- 
  -- 27. Error: get_unique_values works for list (@test-get-unique-values.R#35)  -
  the condition has length > 1
  Backtrace:
   1. testthat::expect_is(get_unique_values(list_x), class = "list")
   5. landscapemetrics:::get_unique_values.list(list_x)
   6. base::lapply(...)
   7. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape = landscape, directions = directions, 
      resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape = landscape, directions = directions, 
      resolution = resolution)
  where 2: lsm_p_cai_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_c_cai_cv_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 5: lsm_c_cai_cv.RasterLayer(landscape)
  where 6 at testthat/test-lsm-c-cai-cv.R#3: lsm_c_cai_cv(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 28. Error: (unknown) (@test-lsm-c-cai-cv.R#3)  ------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_cai_cv(landscape)
   2. landscapemetrics:::lsm_c_cai_cv.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_cai_calc(...)
   6. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape = landscape, directions = directions, 
      resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape = landscape, directions = directions, 
      resolution = resolution)
  where 2: lsm_p_cai_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_c_cai_mn_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 5: lsm_c_cai_mn.RasterLayer(landscape)
  where 6 at testthat/test-lsm-c-cai-mn.R#3: lsm_c_cai_mn(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 29. Error: (unknown) (@test-lsm-c-cai-mn.R#3)  ------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_cai_mn(landscape)
   2. landscapemetrics:::lsm_c_cai_mn.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_cai_calc(...)
   6. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape = landscape, directions = directions, 
      resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape = landscape, directions = directions, 
      resolution = resolution)
  where 2: lsm_p_cai_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_c_cai_sd_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 5: lsm_c_cai_sd.RasterLayer(landscape)
  where 6 at testthat/test-lsm-c-cai-sd.R#3: lsm_c_cai_sd(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 30. Error: (unknown) (@test-lsm-c-cai-sd.R#3)  ------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_cai_sd(landscape)
   2. landscapemetrics:::lsm_c_cai_sd.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_cai_calc(...)
   6. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_circle_calc(landscape, directions = directions, resolution = resolution, 
      points = points)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_c_circle_cv_calc, 
      directions = directions)
  where 5: lsm_c_circle_cv.RasterLayer(landscape)
  where 6 at testthat/test-lsm-c-circle-cv.R#3: lsm_c_circle_cv(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 31. Error: (unknown) (@test-lsm-c-circle-cv.R#3)  ---------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_circle_cv(landscape)
   2. landscapemetrics:::lsm_c_circle_cv.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_circle_calc(...)
   6. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_circle_calc(landscape, directions = directions, resolution = resolution, 
      points = points)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_c_circle_mn_calc, 
      directions = directions)
  where 5: lsm_c_circle_mn.RasterLayer(landscape)
  where 6 at testthat/test-lsm-c-circle-mn.R#3: lsm_c_circle_mn(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 32. Error: (unknown) (@test-lsm-c-circle-mn.R#3)  ---------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_circle_mn(landscape)
   2. landscapemetrics:::lsm_c_circle_mn.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_circle_calc(...)
   6. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_circle_calc(landscape, directions = directions, resolution = resolution, 
      points = points)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_c_circle_sd_calc, 
      directions = directions)
  where 5: lsm_c_circle_sd.RasterLayer(landscape)
  where 6 at testthat/test-lsm-c-circle-sd.R#3: lsm_c_circle_sd(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 33. Error: (unknown) (@test-lsm-c-circle-sd.R#3)  ---------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_circle_sd(landscape)
   2. landscapemetrics:::lsm_c_circle_sd.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_circle_calc(...)
   6. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: FUN(X[[i]], ...)
  where 3: lapply(X = raster::as.list(landscape), FUN = lsm_c_cohesion_calc, 
      directions = directions)
  where 4: lsm_c_cohesion.RasterLayer(landscape)
  where 5 at testthat/test-lsm-c-cohesion.R#3: lsm_c_cohesion(landscape)
  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(NULL, exprs, env)
  where 17: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 18: force(code)
  where 19: doWithOneRestart(return(expr), restart)
  where 20: withOneRestart(expr, restarts[[1L]])
  where 21: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 22: 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 23: FUN(X[[i]], ...)
  where 24: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 25: force(code)
  where 26: doWithOneRestart(return(expr), restart)
  where 27: withOneRestart(expr, restarts[[1L]])
  where 28: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 29: 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 30: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 31: 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 32: 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 33: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 34. Error: (unknown) (@test-lsm-c-cohesion.R#3)  ----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_cohesion(landscape)
   2. landscapemetrics:::lsm_c_cohesion.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  }))
  where 10: lsm_p_core_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, resolution = resolution)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_c_core_cv_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_c_core_cv.RasterLayer(landscape)
  where 14 at testthat/test-lsm-c-core-cv.R#3: lsm_c_core_cv(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 35. Error: (unknown) (@test-lsm-c-core-cv.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_c_core_cv(landscape)
    2. landscapemetrics:::lsm_c_core_cv.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_core_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  }))
  where 10: lsm_p_core_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, resolution = resolution)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_c_core_mn_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_c_core_mn.RasterLayer(landscape)
  where 14 at testthat/test-lsm-c-core-mn.R#3: lsm_c_core_mn(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 36. Error: (unknown) (@test-lsm-c-core-mn.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_c_core_mn(landscape)
    2. landscapemetrics:::lsm_c_core_mn.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_core_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  }))
  where 10: lsm_p_core_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, resolution = resolution)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_c_core_sd_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_c_core_sd.RasterLayer(landscape)
  where 14 at testthat/test-lsm-c-core-sd.R#3: lsm_c_core_sd(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 37. Error: (unknown) (@test-lsm-c-core-sd.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_c_core_sd(landscape)
    2. landscapemetrics:::lsm_c_core_sd.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_core_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: FUN(X[[i]], ...)
  where 3: lapply(X = raster::as.list(landscape), FUN = lsm_c_cpland_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 4: lsm_c_cpland.RasterLayer(landscape)
  where 5 at testthat/test-lsm-c-cpland.R#3: lsm_c_cpland(landscape)
  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(NULL, exprs, env)
  where 17: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 18: force(code)
  where 19: doWithOneRestart(return(expr), restart)
  where 20: withOneRestart(expr, restarts[[1L]])
  where 21: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 22: 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 23: FUN(X[[i]], ...)
  where 24: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 25: force(code)
  where 26: doWithOneRestart(return(expr), restart)
  where 27: withOneRestart(expr, restarts[[1L]])
  where 28: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 29: 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 30: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 31: 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 32: 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 33: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 38. Error: (unknown) (@test-lsm-c-cpland.R#3)  ------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_cpland(landscape)
   2. landscapemetrics:::lsm_c_cpland.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  }))
  where 10: lsm_p_ncore_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, points = points)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_c_dcad_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_c_dcad.RasterLayer(landscape)
  where 14 at testthat/test-lsm-c-dcad.R#3: lsm_c_dcad(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 39. Error: (unknown) (@test-lsm-c-dcad.R#3)  --------------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_c_dcad(landscape)
    2. landscapemetrics:::lsm_c_dcad.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_ncore_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  }))
  where 10: lsm_p_ncore_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, points = points)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_c_dcore_cv_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_c_dcore_cv.RasterLayer(landscape)
  where 14 at testthat/test-lsm-c-dcore_cv.R#3: lsm_c_dcore_cv(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 40. Error: (unknown) (@test-lsm-c-dcore_cv.R#3)  ----------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_c_dcore_cv(landscape)
    2. landscapemetrics:::lsm_c_dcore_cv.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_ncore_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  }))
  where 10: lsm_p_ncore_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, points = points)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_c_dcore_mn_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_c_dcore_mn.RasterLayer(landscape)
  where 14 at testthat/test-lsm-c-dcore_mn.R#3: lsm_c_dcore_mn(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 41. Error: (unknown) (@test-lsm-c-dcore_mn.R#3)  ----------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_c_dcore_mn(landscape)
    2. landscapemetrics:::lsm_c_dcore_mn.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_ncore_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  }))
  where 10: lsm_p_ncore_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, points = points)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_c_dcore_sd_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_c_dcore_sd.RasterLayer(landscape)
  where 14 at testthat/test-lsm-c-dcore_sd.R#3: lsm_c_dcore_sd(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 42. Error: (unknown) (@test-lsm-c-dcore_sd.R#3)  ----------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_c_dcore_sd(landscape)
    2. landscapemetrics:::lsm_c_dcore_sd.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_ncore_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: FUN(X[[i]], ...)
  where 3: lapply(X = raster::as.list(landscape), FUN = lsm_c_ed_calc, count_boundary = count_boundary, 
      directions = directions)
  where 4: lsm_c_ed.RasterLayer(landscape)
  where 5 at testthat/test-lsm-c-ed.R#3: lsm_c_ed(landscape)
  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(NULL, exprs, env)
  where 17: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 18: force(code)
  where 19: doWithOneRestart(return(expr), restart)
  where 20: withOneRestart(expr, restarts[[1L]])
  where 21: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 22: 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 23: FUN(X[[i]], ...)
  where 24: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 25: force(code)
  where 26: doWithOneRestart(return(expr), restart)
  where 27: withOneRestart(expr, restarts[[1L]])
  where 28: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 29: 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 30: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 31: 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 32: 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 33: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 43. Error: (unknown) (@test-lsm-c-ed.R#3)  ----------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_ed(landscape)
   2. landscapemetrics:::lsm_c_ed.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, as_NA = TRUE)
  where 6: get_boundaries(landscape_labeled, directions = 4, as_NA = TRUE)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      np_class <- max(landscape_labeled, na.rm = TRUE)
      if (np_class == 1) {
          enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
          if (verbose) {
              warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                  call. = FALSE)
          }
      }
      else {
          class_boundaries <- get_boundaries(landscape_labeled, 
              directions = 4, as_NA = TRUE)[[1]]
          class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
          class_boundaries <- t(class_boundaries)
          points <- points[which(!is.na(class_boundaries)), ]
          points[, 3] <- class_boundaries[!is.na(class_boundaries)]
          ord <- order(as.matrix(points)[, 1])
          num <- seq_along(ord)
          rank <- match(num, ord)
          res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
              ])
          min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
              3]))
          tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
              2], id = min_dist[, 3])
          enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 3], 
              FUN = min)
      }
      tibble::tibble(class = patches_class, value = enn$dist)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      np_class <- max(landscape_labeled, na.rm = TRUE)
      if (np_class == 1) {
          enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
          if (verbose) {
              warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                  call. = FALSE)
          }
      }
      else {
          class_boundaries <- get_boundaries(landscape_labeled, 
              directions = 4, as_NA = TRUE)[[1]]
          class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
          class_boundaries <- t(class_boundaries)
          points <- points[which(!is.na(class_boundaries)), ]
          points[, 3] <- class_boundaries[!is.na(class_boundaries)]
          ord <- order(as.matrix(points)[, 1])
          num <- seq_along(ord)
          rank <- match(num, ord)
          res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
              ])
          min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
              3]))
          tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
              2], id = min_dist[, 3])
          enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 3], 
              FUN = min)
      }
      tibble::tibble(class = patches_class, value = enn$dist)
  }))
  where 10: lsm_p_enn_calc(landscape, directions = directions, verbose = verbose, 
      points = points)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_c_enn_cv_calc, 
      directions = directions, verbose = verbose)
  where 13: lsm_c_enn_cv.RasterLayer(landscape)
  where 14 at testthat/test-lsm-c-enn-cv.R#3: lsm_c_enn_cv(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 44. Error: (unknown) (@test-lsm-c-enn-cv.R#3)  ------------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_c_enn_cv(landscape)
    2. landscapemetrics:::lsm_c_enn_cv.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_enn_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, as_NA = TRUE)
  where 6: get_boundaries(landscape_labeled, directions = 4, as_NA = TRUE)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      np_class <- max(landscape_labeled, na.rm = TRUE)
      if (np_class == 1) {
          enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
          if (verbose) {
              warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                  call. = FALSE)
          }
      }
      else {
          class_boundaries <- get_boundaries(landscape_labeled, 
              directions = 4, as_NA = TRUE)[[1]]
          class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
          class_boundaries <- t(class_boundaries)
          points <- points[which(!is.na(class_boundaries)), ]
          points[, 3] <- class_boundaries[!is.na(class_boundaries)]
          ord <- order(as.matrix(points)[, 1])
          num <- seq_along(ord)
          rank <- match(num, ord)
          res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
              ])
          min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
              3]))
          tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
              2], id = min_dist[, 3])
          enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 3], 
              FUN = min)
      }
      tibble::tibble(class = patches_class, value = enn$dist)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      np_class <- max(landscape_labeled, na.rm = TRUE)
      if (np_class == 1) {
          enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
          if (verbose) {
              warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                  call. = FALSE)
          }
      }
      else {
          class_boundaries <- get_boundaries(landscape_labeled, 
              directions = 4, as_NA = TRUE)[[1]]
          class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
          class_boundaries <- t(class_boundaries)
          points <- points[which(!is.na(class_boundaries)), ]
          points[, 3] <- class_boundaries[!is.na(class_boundaries)]
          ord <- order(as.matrix(points)[, 1])
          num <- seq_along(ord)
          rank <- match(num, ord)
          res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
              ])
          min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
              3]))
          tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
              2], id = min_dist[, 3])
          enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 3], 
              FUN = min)
      }
      tibble::tibble(class = patches_class, value = enn$dist)
  }))
  where 10: lsm_p_enn_calc(landscape, directions = directions, verbose = verbose, 
      points = points)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_c_enn_mn_calc, 
      directions = directions, verbose = verbose)
  where 13: lsm_c_enn_mn.RasterLayer(landscape)
  where 14 at testthat/test-lsm-c-enn-mn.R#3: lsm_c_enn_mn(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 45. Error: (unknown) (@test-lsm-c-enn-mn.R#3)  ------------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_c_enn_mn(landscape)
    2. landscapemetrics:::lsm_c_enn_mn.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_enn_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, as_NA = TRUE)
  where 6: get_boundaries(landscape_labeled, directions = 4, as_NA = TRUE)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      np_class <- max(landscape_labeled, na.rm = TRUE)
      if (np_class == 1) {
          enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
          if (verbose) {
              warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                  call. = FALSE)
          }
      }
      else {
          class_boundaries <- get_boundaries(landscape_labeled, 
              directions = 4, as_NA = TRUE)[[1]]
          class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
          class_boundaries <- t(class_boundaries)
          points <- points[which(!is.na(class_boundaries)), ]
          points[, 3] <- class_boundaries[!is.na(class_boundaries)]
          ord <- order(as.matrix(points)[, 1])
          num <- seq_along(ord)
          rank <- match(num, ord)
          res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
              ])
          min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
              3]))
          tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
              2], id = min_dist[, 3])
          enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 3], 
              FUN = min)
      }
      tibble::tibble(class = patches_class, value = enn$dist)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      np_class <- max(landscape_labeled, na.rm = TRUE)
      if (np_class == 1) {
          enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
          if (verbose) {
              warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                  call. = FALSE)
          }
      }
      else {
          class_boundaries <- get_boundaries(landscape_labeled, 
              directions = 4, as_NA = TRUE)[[1]]
          class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
          class_boundaries <- t(class_boundaries)
          points <- points[which(!is.na(class_boundaries)), ]
          points[, 3] <- class_boundaries[!is.na(class_boundaries)]
          ord <- order(as.matrix(points)[, 1])
          num <- seq_along(ord)
          rank <- match(num, ord)
          res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
              ])
          min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
              3]))
          tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
              2], id = min_dist[, 3])
          enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 3], 
              FUN = min)
      }
      tibble::tibble(class = patches_class, value = enn$dist)
  }))
  where 10: lsm_p_enn_calc(landscape, directions = directions, verbose = verbose, 
      points = points)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_c_enn_sd_calc, 
      directions = directions, verbose = verbose)
  where 13: lsm_c_enn_sd.RasterLayer(landscape)
  where 14 at testthat/test-lsm-c-enn-sd.R#3: lsm_c_enn_sd(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 46. Error: (unknown) (@test-lsm-c-enn-sd.R#3)  ------------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_c_enn_sd(landscape)
    2. landscapemetrics:::lsm_c_enn_sd.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_enn_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_frac_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_c_frac_cv_calc, 
      directions = directions)
  where 5: lsm_c_frac_cv.RasterLayer(landscape)
  where 6 at testthat/test-lsm-c-frac-cv.R#3: lsm_c_frac_cv(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 47. Error: (unknown) (@test-lsm-c-frac-cv.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_frac_cv(landscape)
   2. landscapemetrics:::lsm_c_frac_cv.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_frac_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_frac_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_c_frac_mn_calc, 
      directions = directions)
  where 5: lsm_c_frac_mn.RasterLayer(landscape)
  where 6 at testthat/test-lsm-c-frac-mn.R#3: lsm_c_frac_mn(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 48. Error: (unknown) (@test-lsm-c-frac-mn.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_frac_mn(landscape)
   2. landscapemetrics:::lsm_c_frac_mn.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_frac_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_frac_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_c_frac_sd_calc, 
      directions = directions)
  where 5: lsm_c_frac_sd.RasterLayer(landscape)
  where 6 at testthat/test-lsm-c-frac-sd.R#3: lsm_c_frac_sd(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 49. Error: (unknown) (@test-lsm-c-frac-sd.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_frac_sd(landscape)
   2. landscapemetrics:::lsm_c_frac_sd.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_frac_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_c_te_calc(landscape, directions = directions, count_boundary = TRUE, 
      resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_c_te_calc(landscape, directions = directions, count_boundary = TRUE, 
      resolution = resolution)
  where 2: FUN(X[[i]], ...)
  where 3: lapply(X = raster::as.list(landscape), FUN = lsm_c_lsi_calc, 
      directions = directions)
  where 4: lsm_c_lsi.RasterLayer(landscape)
  where 5 at testthat/test-lsm-c-lsi.R#3: lsm_c_lsi(landscape)
  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(NULL, exprs, env)
  where 17: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 18: force(code)
  where 19: doWithOneRestart(return(expr), restart)
  where 20: withOneRestart(expr, restarts[[1L]])
  where 21: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 22: 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 23: FUN(X[[i]], ...)
  where 24: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 25: force(code)
  where 26: doWithOneRestart(return(expr), restart)
  where 27: withOneRestart(expr, restarts[[1L]])
  where 28: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 29: 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 30: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 31: 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 32: 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 33: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, count_boundary, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (length(classes) == 1 && !count_boundary) {
          tibble::tibble(level = "class", class = as.integer(classes), 
              id = as.integer(NA), metric = "te", value = as.double(0))
      }
      else {
          if (resolution_x != resolution_y) {
              top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, 
                  NA, NA, NA), 3, 3, byrow = TRUE)
              left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, 
                  NA, 1, NA), 3, 3, byrow = TRUE)
          }
          do.call(rbind, lapply(X = classes, FUN = function(patches_class) {
              landscape_labeled <- get_patches(landscape, class = patches_class, 
                  directions = directions, return_raster = FALSE)[[1]]
              landscape_labeled[is.na(landscape_labeled)] <- -999
              if (count_boundary) {
                  landscape_labeled <- pad_raster(landscape = landscape_labeled, 
                    pad_raster_value = -999, pad_raster_cells = 1, 
                    return_raster = FALSE)[[1]]
              }
              if (resolution_x == resolution_y) {
                  neighbor_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                    directions = as.matrix(4))
                  edge_ik <- (sum(neighbor_matrix[2:ncol(neighbor_matrix), 
                    1])) * resolution_x
              }
              else {
                  left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                    directions = as.matrix(left_right_matrix))
                  edge_ik_left_right <- sum(left_right_neighbours[1, 
                    2:ncol(left_right_neighbours)]) * resolution_x
                  top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                    directions = as.matrix(top_bottom_matrix))
                  edge_ik_top_bottom <- sum(top_bottom_neighbours[1, 
                    2:ncol(top_bottom_neighbours)]) * resolution_y
                  edge_ik <- edge_ik_left_right + edge_ik_top_bottom
              }
              tibble::tibble(level = "class", class = as.integer(patches_class), 
                  id = as.integer(NA), metric = "te", value = as.double(edge_ik))
          }))
      }
  }
  <bytecode: 0x7f3c818>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_c_te_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 50. Error: (unknown) (@test-lsm-c-lsi.R#3)  ---------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_lsi(landscape)
   2. landscapemetrics:::lsm_c_lsi.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_c_te_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  }))
  where 10: lsm_p_ncore_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, points = points)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_c_ndca_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_c_ndca.RasterLayer(landscape)
  where 14 at testthat/test-lsm-c-ndca.R#3: lsm_c_ndca(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 51. Error: (unknown) (@test-lsm-c-ndca.R#3)  --------------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_c_ndca(landscape)
    2. landscapemetrics:::lsm_c_ndca.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_ncore_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_c_te_calc(landscape, directions = directions, count_boundary = TRUE, 
      resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_c_te_calc(landscape, directions = directions, count_boundary = TRUE, 
      resolution = resolution)
  where 2: FUN(X[[i]], ...)
  where 3: lapply(X = raster::as.list(landscape), FUN = lsm_c_nlsi_calc, 
      directions = directions)
  where 4: lsm_c_nlsi.RasterLayer(landscape)
  where 5 at testthat/test-lsm-c-nlsi.R#3: lsm_c_nlsi(landscape)
  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(NULL, exprs, env)
  where 17: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 18: force(code)
  where 19: doWithOneRestart(return(expr), restart)
  where 20: withOneRestart(expr, restarts[[1L]])
  where 21: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 22: 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 23: FUN(X[[i]], ...)
  where 24: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 25: force(code)
  where 26: doWithOneRestart(return(expr), restart)
  where 27: withOneRestart(expr, restarts[[1L]])
  where 28: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 29: 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 30: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 31: 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 32: 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 33: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, count_boundary, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (length(classes) == 1 && !count_boundary) {
          tibble::tibble(level = "class", class = as.integer(classes), 
              id = as.integer(NA), metric = "te", value = as.double(0))
      }
      else {
          if (resolution_x != resolution_y) {
              top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, 
                  NA, NA, NA), 3, 3, byrow = TRUE)
              left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, 
                  NA, 1, NA), 3, 3, byrow = TRUE)
          }
          do.call(rbind, lapply(X = classes, FUN = function(patches_class) {
              landscape_labeled <- get_patches(landscape, class = patches_class, 
                  directions = directions, return_raster = FALSE)[[1]]
              landscape_labeled[is.na(landscape_labeled)] <- -999
              if (count_boundary) {
                  landscape_labeled <- pad_raster(landscape = landscape_labeled, 
                    pad_raster_value = -999, pad_raster_cells = 1, 
                    return_raster = FALSE)[[1]]
              }
              if (resolution_x == resolution_y) {
                  neighbor_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                    directions = as.matrix(4))
                  edge_ik <- (sum(neighbor_matrix[2:ncol(neighbor_matrix), 
                    1])) * resolution_x
              }
              else {
                  left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                    directions = as.matrix(left_right_matrix))
                  edge_ik_left_right <- sum(left_right_neighbours[1, 
                    2:ncol(left_right_neighbours)]) * resolution_x
                  top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                    directions = as.matrix(top_bottom_matrix))
                  edge_ik_top_bottom <- sum(top_bottom_neighbours[1, 
                    2:ncol(top_bottom_neighbours)]) * resolution_y
                  edge_ik <- edge_ik_left_right + edge_ik_top_bottom
              }
              tibble::tibble(level = "class", class = as.integer(patches_class), 
                  id = as.integer(NA), metric = "te", value = as.double(edge_ik))
          }))
      }
  }
  <bytecode: 0x7f3c818>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_c_te_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 52. Error: (unknown) (@test-lsm-c-nlsi.R#3)  --------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_nlsi(landscape)
   2. landscapemetrics:::lsm_c_nlsi.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_c_te_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: FUN(X[[i]], ...)
  where 3: lapply(X = raster::as.list(landscape), FUN = lsm_c_pafrac_calc, 
      directions = directions, verbose = verbose)
  where 4: lsm_c_pafrac.RasterLayer(landscape, verbose = FALSE)
  where 5 at testthat/test-lsm-c-pafrac.R#3: lsm_c_pafrac(landscape, verbose = FALSE)
  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(NULL, exprs, env)
  where 17: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 18: force(code)
  where 19: doWithOneRestart(return(expr), restart)
  where 20: withOneRestart(expr, restarts[[1L]])
  where 21: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 22: 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 23: FUN(X[[i]], ...)
  where 24: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 25: force(code)
  where 26: doWithOneRestart(return(expr), restart)
  where 27: withOneRestart(expr, restarts[[1L]])
  where 28: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 29: 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 30: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 31: 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 32: 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 33: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 53. Error: (unknown) (@test-lsm-c-pafrac.R#3)  ------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_pafrac(landscape, verbose = FALSE)
   2. landscapemetrics:::lsm_c_pafrac.RasterLayer(landscape, verbose = FALSE)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_para_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_c_para_cv_calc, 
      directions = directions)
  where 5: lsm_c_para_cv.RasterLayer(landscape)
  where 6 at testthat/test-lsm-c-para-cv.R#3: lsm_c_para_cv(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 54. Error: (unknown) (@test-lsm-c-para-cv.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_para_cv(landscape)
   2. landscapemetrics:::lsm_c_para_cv.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_para_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_para_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_c_para_mn_calc, 
      directions = directions)
  where 5: lsm_c_para_mn.RasterLayer(landscape)
  where 6 at testthat/test-lsm-c-para-mn.R#3: lsm_c_para_mn(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 55. Error: (unknown) (@test-lsm-c-para-mn.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_para_mn(landscape)
   2. landscapemetrics:::lsm_c_para_mn.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_para_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_para_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_c_para_sd_calc, 
      directions = directions)
  where 5: lsm_c_para_sd.RasterLayer(landscape)
  where 6 at testthat/test-lsm-c-para-sd.R#3: lsm_c_para_sd(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 56. Error: (unknown) (@test-lsm-c-para-sd.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_para_sd(landscape)
   2. landscapemetrics:::lsm_c_para_sd.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_para_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: FUN(X[[i]], ...)
  where 3: lapply(X = raster::as.list(landscape), FUN = lsm_c_pd_calc, directions = directions)
  where 4: lsm_c_pd.RasterLayer(landscape)
  where 5 at testthat/test-lsm-c-pd.R#3: lsm_c_pd(landscape)
  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(NULL, exprs, env)
  where 17: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 18: force(code)
  where 19: doWithOneRestart(return(expr), restart)
  where 20: withOneRestart(expr, restarts[[1L]])
  where 21: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 22: 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 23: FUN(X[[i]], ...)
  where 24: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 25: force(code)
  where 26: doWithOneRestart(return(expr), restart)
  where 27: withOneRestart(expr, restarts[[1L]])
  where 28: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 29: 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 30: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 31: 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 32: 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 33: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 57. Error: (unknown) (@test-lsm-c-pd.R#3)  ----------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_pd(landscape)
   2. landscapemetrics:::lsm_c_pd.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = -999, pad_raster_cells = 1, 
      return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = -999, pad_raster_cells = 1, 
      return_raster = FALSE)
  where 5: FUN(X[[i]], ...)
  where 6: lapply(X = raster::as.list(landscape), FUN = lsm_c_pladj_calc)
  where 7: lsm_c_pladj.RasterLayer(landscape)
  where 8 at testthat/test-lsm-c-pladj.R#3: lsm_c_pladj(landscape)
  where 9: eval(code, test_env)
  where 10: eval(code, test_env)
  where 11: 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 12: doTryCatch(return(expr), name, parentenv, handler)
  where 13: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 14: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 15: doTryCatch(return(expr), name, parentenv, handler)
  where 16: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 17: tryCatchList(expr, classes, parentenv, handlers)
  where 18: 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 19: test_code(NULL, exprs, env)
  where 20: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 21: force(code)
  where 22: doWithOneRestart(return(expr), restart)
  where 23: withOneRestart(expr, restarts[[1L]])
  where 24: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 25: 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 26: FUN(X[[i]], ...)
  where 27: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 28: force(code)
  where 29: doWithOneRestart(return(expr), restart)
  where 30: withOneRestart(expr, restarts[[1L]])
  where 31: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 32: 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 33: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 34: 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 35: 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 36: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 58. Error: (unknown) (@test-lsm-c-pladj.R#3)  -------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_pladj(landscape)
   2. landscapemetrics:::lsm_c_pladj.RasterLayer(landscape)
   3. base::lapply(X = raster::as.list(landscape), FUN = lsm_c_pladj_calc)
   4. landscapemetrics:::FUN(X[[i]], ...)
   6. landscapemetrics:::pad_raster.matrix(...)
   7. base::lapply(...)
   8. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_shape_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_c_shape_cv_calc, 
      directions = directions)
  where 5: lsm_c_shape_cv.RasterLayer(landscape)
  where 6 at testthat/test-lsm-c-shape-cv.R#3: lsm_c_shape_cv(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 59. Error: (unknown) (@test-lsm-c-shape-cv.R#3)  ----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_shape_cv(landscape)
   2. landscapemetrics:::lsm_c_shape_cv.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_shape_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_shape_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_c_shape_mn_calc, 
      directions = directions)
  where 5: lsm_c_shape_mn.RasterLayer(landscape)
  where 6 at testthat/test-lsm-c-shape-mn.R#3: lsm_c_shape_mn(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 60. Error: (unknown) (@test-lsm-c-shape-mn.R#3)  ----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_shape_mn(landscape)
   2. landscapemetrics:::lsm_c_shape_mn.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_shape_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_shape_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_c_shape_sd_calc, 
      directions = directions)
  where 5: lsm_c_shape_sd.RasterLayer(landscape)
  where 6 at testthat/test-lsm-c-shape-sd.R#3: lsm_c_shape_sd(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 61. Error: (unknown) (@test-lsm-c-shape-sd.R#3)  ----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_c_shape_sd(landscape)
   2. landscapemetrics:::lsm_c_shape_sd.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_shape_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  }))
  where 10: lsm_p_core_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, resolution = resolution)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_c_tca_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_c_tca.RasterLayer(landscape)
  where 14 at testthat/test-lsm-c-tca.R#3: lsm_c_tca(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 62. Error: (unknown) (@test-lsm-c-tca.R#3)  ---------------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_c_tca(landscape)
    2. landscapemetrics:::lsm_c_tca.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_core_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_c_ai_calc(landscape)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_c_ai_calc(landscape)
  where 2: FUN(X[[i]], ...)
  where 3: lapply(X = raster::as.list(landscape), FUN = lsm_l_ai_calc)
  where 4: lsm_l_ai.RasterLayer(landscape)
  where 5 at testthat/test-lsm-l-ai.R#3: lsm_l_ai(landscape)
  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(NULL, exprs, env)
  where 17: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 18: force(code)
  where 19: doWithOneRestart(return(expr), restart)
  where 20: withOneRestart(expr, restarts[[1L]])
  where 21: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 22: 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 23: FUN(X[[i]], ...)
  where 24: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 25: force(code)
  where 26: doWithOneRestart(return(expr), restart)
  where 27: withOneRestart(expr, restarts[[1L]])
  where 28: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 29: 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 30: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 31: 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 32: 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 33: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      like_adjacencies <- rcpp_get_coocurrence_matrix_diag(landscape, 
          directions = as.matrix(4))/2
      cells_class <- rcpp_get_composition_vector(landscape)
      cells_class <- tibble::tibble(class = names(cells_class), 
          value = cells_class)
      cells_class$n <- trunc(sqrt(cells_class$value))
      cells_class$m <- cells_class$value - cells_class$n^2
      cells_class$max_adj <- ifelse(test = cells_class$m == 0, 
          yes = 2 * cells_class$n * (cells_class$n - 1), no = ifelse(test = cells_class$m <= 
              cells_class$n, yes = 2 * cells_class$n * (cells_class$n - 
              1) + 2 * cells_class$m - 1, no = ifelse(test = cells_class$m > 
              cells_class$n, yes = 2 * cells_class$n * (cells_class$n - 
              1) + 2 * cells_class$m - 2, no = NA)))
      if (anyNA(cells_class$max_adj)) {
          warning("NAs introduced by lsm_c_ai", call. = FALSE)
      }
      max_adj <- cells_class$max_adj
      ai <- (like_adjacencies/max_adj) * 100
      ai[is.nan(ai)] <- NA
      tibble::tibble(level = "class", class = as.integer(names(like_adjacencies)), 
          id = as.integer(NA), metric = "ai", value = as.double(ai))
  }
  <bytecode: 0x82d9980>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_c_ai_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 63. Error: (unknown) (@test-lsm-l-ai.R#3)  ----------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_ai(landscape)
   2. landscapemetrics:::lsm_l_ai.RasterLayer(landscape)
   3. base::lapply(X = raster::as.list(landscape), FUN = lsm_l_ai_calc)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_c_ai_calc(landscape)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape = landscape, directions = directions, 
      resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape = landscape, directions = directions, 
      resolution = resolution)
  where 2: lsm_p_cai_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_l_cai_cv_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 5: lsm_l_cai_cv.RasterLayer(landscape)
  where 6 at testthat/test-lsm-l-cai-cv.R#3: lsm_l_cai_cv(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 64. Error: (unknown) (@test-lsm-l-cai-cv.R#3)  ------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_cai_cv(landscape)
   2. landscapemetrics:::lsm_l_cai_cv.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_cai_calc(...)
   6. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape = landscape, directions = directions, 
      resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape = landscape, directions = directions, 
      resolution = resolution)
  where 2: lsm_p_cai_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_l_cai_mn_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 5: lsm_l_cai_mn.RasterLayer(landscape)
  where 6 at testthat/test-lsm-l-cai-mn.R#3: lsm_l_cai_mn(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 65. Error: (unknown) (@test-lsm-l-cai-mn.R#3)  ------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_cai_mn(landscape)
   2. landscapemetrics:::lsm_l_cai_mn.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_cai_calc(...)
   6. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape = landscape, directions = directions, 
      resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape = landscape, directions = directions, 
      resolution = resolution)
  where 2: lsm_p_cai_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_l_cai_sd_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 5: lsm_l_cai_sd.RasterLayer(landscape)
  where 6 at testthat/test-lsm-l-cai-sd.R#3: lsm_l_cai_sd(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 66. Error: (unknown) (@test-lsm-l-cai-sd.R#3)  ------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_cai_sd(landscape)
   2. landscapemetrics:::lsm_l_cai_sd.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_cai_calc(...)
   6. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_circle_calc(landscape, directions = directions, resolution = resolution, 
      points = points)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_l_circle_cv_calc, 
      directions = directions)
  where 5: lsm_l_circle_cv.RasterLayer(landscape)
  where 6 at testthat/test-lsm-l-circle-cv.R#3: lsm_l_circle_cv(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 67. Error: (unknown) (@test-lsm-l-circle-cv.R#3)  ---------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_circle_cv(landscape)
   2. landscapemetrics:::lsm_l_circle_cv.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_circle_calc(...)
   6. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_circle_calc(landscape, directions = directions, resolution = resolution, 
      points = points)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_l_circle_mn_calc, 
      directions = directions)
  where 5: lsm_l_circle_mn.RasterLayer(landscape)
  where 6 at testthat/test-lsm-l-circle-mn.R#3: lsm_l_circle_mn(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 68. Error: (unknown) (@test-lsm-l-circle-mn.R#3)  ---------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_circle_mn(landscape)
   2. landscapemetrics:::lsm_l_circle_mn.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_circle_calc(...)
   6. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_circle_calc(landscape, directions = directions, resolution = resolution, 
      points = points)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_l_circle_sd_calc, 
      directions = directions)
  where 5: lsm_l_circle_sd.RasterLayer(landscape)
  where 6 at testthat/test-lsm-l-circle-sd.R#3: lsm_l_circle_sd(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 69. Error: (unknown) (@test-lsm-l-circle-sd.R#3)  ---------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_circle_sd(landscape)
   2. landscapemetrics:::lsm_l_circle_sd.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_circle_calc(...)
   6. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: FUN(X[[i]], ...)
  where 3: lapply(X = raster::as.list(landscape), FUN = lsm_l_cohesion_calc, 
      directions = directions)
  where 4: lsm_l_cohesion.RasterLayer(landscape)
  where 5 at testthat/test-lsm-l-cohesion.R#3: lsm_l_cohesion(landscape)
  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(NULL, exprs, env)
  where 17: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 18: force(code)
  where 19: doWithOneRestart(return(expr), restart)
  where 20: withOneRestart(expr, restarts[[1L]])
  where 21: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 22: 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 23: FUN(X[[i]], ...)
  where 24: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 25: force(code)
  where 26: doWithOneRestart(return(expr), restart)
  where 27: withOneRestart(expr, restarts[[1L]])
  where 28: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 29: 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 30: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 31: 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 32: 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 33: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 70. Error: (unknown) (@test-lsm-l-cohesion.R#3)  ----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_cohesion(landscape)
   2. landscapemetrics:::lsm_l_cohesion.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  }))
  where 10: lsm_p_core_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, resolution = resolution)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_l_core_cv_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_l_core_cv.RasterLayer(landscape)
  where 14 at testthat/test-lsm-l-core-cv.R#3: lsm_l_core_cv(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 71. Error: (unknown) (@test-lsm-l-core-cv.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_l_core_cv(landscape)
    2. landscapemetrics:::lsm_l_core_cv.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_core_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  }))
  where 10: lsm_p_core_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, resolution = resolution)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_l_core_mn_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_l_core_mn.RasterLayer(landscape)
  where 14 at testthat/test-lsm-l-core-mn.R#3: lsm_l_core_mn(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 72. Error: (unknown) (@test-lsm-l-core-mn.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_l_core_mn(landscape)
    2. landscapemetrics:::lsm_l_core_mn.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_core_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  }))
  where 10: lsm_p_core_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, resolution = resolution)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_l_core_sd_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_l_core_sd.RasterLayer(landscape)
  where 14 at testthat/test-lsm-l-core-sd.R#3: lsm_l_core_sd(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 73. Error: (unknown) (@test-lsm-l-core-sd.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_l_core_sd(landscape)
    2. landscapemetrics:::lsm_l_core_sd.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_core_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  }))
  where 10: lsm_p_ncore_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, points = points)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_l_dcad_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_l_dcad.RasterLayer(landscape)
  where 14 at testthat/test-lsm-l-dcad.R#3: lsm_l_dcad(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 74. Error: (unknown) (@test-lsm-l-dcad.R#3)  --------------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_l_dcad(landscape)
    2. landscapemetrics:::lsm_l_dcad.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_ncore_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  }))
  where 10: lsm_p_ncore_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, points = points)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_l_dcore_cv_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_l_dcore_cv.RasterLayer(landscape)
  where 14 at testthat/test-lsm-l-dcore-cv.R#3: lsm_l_dcore_cv(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 75. Error: (unknown) (@test-lsm-l-dcore-cv.R#3)  ----------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_l_dcore_cv(landscape)
    2. landscapemetrics:::lsm_l_dcore_cv.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_ncore_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  }))
  where 10: lsm_p_ncore_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, points = points)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_l_dcore_mn_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_l_dcore_mn.RasterLayer(landscape)
  where 14 at testthat/test-lsm-l-dcore-mn.R#3: lsm_l_dcore_mn(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 76. Error: (unknown) (@test-lsm-l-dcore-mn.R#3)  ----------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_l_dcore_mn(landscape)
    2. landscapemetrics:::lsm_l_dcore_mn.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_ncore_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  }))
  where 10: lsm_p_ncore_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, points = points)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_l_dcore_sd_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_l_dcore_sd.RasterLayer(landscape)
  where 14 at testthat/test-lsm-l-dcore-sd.R#3: lsm_l_dcore_sd(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 77. Error: (unknown) (@test-lsm-l-dcore-sd.R#3)  ----------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_l_dcore_sd(landscape)
    2. landscapemetrics:::lsm_l_dcore_sd.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_ncore_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: FUN(X[[i]], ...)
  where 3: lapply(X = raster::as.list(landscape), FUN = lsm_l_ed_calc, count_boundary = count_boundary, 
      directions = directions)
  where 4: lsm_l_ed.RasterLayer(landscape)
  where 5 at testthat/test-lsm-l-ed.R#3: lsm_l_ed(landscape)
  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(NULL, exprs, env)
  where 17: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 18: force(code)
  where 19: doWithOneRestart(return(expr), restart)
  where 20: withOneRestart(expr, restarts[[1L]])
  where 21: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 22: 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 23: FUN(X[[i]], ...)
  where 24: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 25: force(code)
  where 26: doWithOneRestart(return(expr), restart)
  where 27: withOneRestart(expr, restarts[[1L]])
  where 28: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 29: 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 30: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 31: 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 32: 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 33: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 78. Error: (unknown) (@test-lsm-l-ed.R#3)  ----------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_ed(landscape)
   2. landscapemetrics:::lsm_l_ed.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, as_NA = TRUE)
  where 6: get_boundaries(landscape_labeled, directions = 4, as_NA = TRUE)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      np_class <- max(landscape_labeled, na.rm = TRUE)
      if (np_class == 1) {
          enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
          if (verbose) {
              warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                  call. = FALSE)
          }
      }
      else {
          class_boundaries <- get_boundaries(landscape_labeled, 
              directions = 4, as_NA = TRUE)[[1]]
          class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
          class_boundaries <- t(class_boundaries)
          points <- points[which(!is.na(class_boundaries)), ]
          points[, 3] <- class_boundaries[!is.na(class_boundaries)]
          ord <- order(as.matrix(points)[, 1])
          num <- seq_along(ord)
          rank <- match(num, ord)
          res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
              ])
          min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
              3]))
          tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
              2], id = min_dist[, 3])
          enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 3], 
              FUN = min)
      }
      tibble::tibble(class = patches_class, value = enn$dist)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      np_class <- max(landscape_labeled, na.rm = TRUE)
      if (np_class == 1) {
          enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
          if (verbose) {
              warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                  call. = FALSE)
          }
      }
      else {
          class_boundaries <- get_boundaries(landscape_labeled, 
              directions = 4, as_NA = TRUE)[[1]]
          class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
          class_boundaries <- t(class_boundaries)
          points <- points[which(!is.na(class_boundaries)), ]
          points[, 3] <- class_boundaries[!is.na(class_boundaries)]
          ord <- order(as.matrix(points)[, 1])
          num <- seq_along(ord)
          rank <- match(num, ord)
          res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
              ])
          min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
              3]))
          tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
              2], id = min_dist[, 3])
          enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 3], 
              FUN = min)
      }
      tibble::tibble(class = patches_class, value = enn$dist)
  }))
  where 10: lsm_p_enn_calc(landscape, directions = directions, verbose = verbose, 
      points = points)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_l_enn_cv_calc, 
      directions = directions, verbose = verbose)
  where 13: lsm_l_enn_cv.RasterLayer(landscape)
  where 14 at testthat/test-lsm-l-enn-cv.R#3: lsm_l_enn_cv(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 79. Error: (unknown) (@test-lsm-l-enn-cv.R#3)  ------------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_l_enn_cv(landscape)
    2. landscapemetrics:::lsm_l_enn_cv.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_enn_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, as_NA = TRUE)
  where 6: get_boundaries(landscape_labeled, directions = 4, as_NA = TRUE)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      np_class <- max(landscape_labeled, na.rm = TRUE)
      if (np_class == 1) {
          enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
          if (verbose) {
              warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                  call. = FALSE)
          }
      }
      else {
          class_boundaries <- get_boundaries(landscape_labeled, 
              directions = 4, as_NA = TRUE)[[1]]
          class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
          class_boundaries <- t(class_boundaries)
          points <- points[which(!is.na(class_boundaries)), ]
          points[, 3] <- class_boundaries[!is.na(class_boundaries)]
          ord <- order(as.matrix(points)[, 1])
          num <- seq_along(ord)
          rank <- match(num, ord)
          res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
              ])
          min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
              3]))
          tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
              2], id = min_dist[, 3])
          enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 3], 
              FUN = min)
      }
      tibble::tibble(class = patches_class, value = enn$dist)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      np_class <- max(landscape_labeled, na.rm = TRUE)
      if (np_class == 1) {
          enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
          if (verbose) {
              warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                  call. = FALSE)
          }
      }
      else {
          class_boundaries <- get_boundaries(landscape_labeled, 
              directions = 4, as_NA = TRUE)[[1]]
          class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
          class_boundaries <- t(class_boundaries)
          points <- points[which(!is.na(class_boundaries)), ]
          points[, 3] <- class_boundaries[!is.na(class_boundaries)]
          ord <- order(as.matrix(points)[, 1])
          num <- seq_along(ord)
          rank <- match(num, ord)
          res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
              ])
          min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
              3]))
          tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
              2], id = min_dist[, 3])
          enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 3], 
              FUN = min)
      }
      tibble::tibble(class = patches_class, value = enn$dist)
  }))
  where 10: lsm_p_enn_calc(landscape, directions = directions, verbose = verbose, 
      points = points)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_l_enn_mn_calc, 
      directions = directions, verbose = verbose)
  where 13: lsm_l_enn_mn.RasterLayer(landscape)
  where 14 at testthat/test-lsm-l-enn-mn.R#3: lsm_l_enn_mn(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 80. Error: (unknown) (@test-lsm-l-enn-mn.R#3)  ------------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_l_enn_mn(landscape)
    2. landscapemetrics:::lsm_l_enn_mn.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_enn_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, as_NA = TRUE)
  where 6: get_boundaries(landscape_labeled, directions = 4, as_NA = TRUE)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      np_class <- max(landscape_labeled, na.rm = TRUE)
      if (np_class == 1) {
          enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
          if (verbose) {
              warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                  call. = FALSE)
          }
      }
      else {
          class_boundaries <- get_boundaries(landscape_labeled, 
              directions = 4, as_NA = TRUE)[[1]]
          class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
          class_boundaries <- t(class_boundaries)
          points <- points[which(!is.na(class_boundaries)), ]
          points[, 3] <- class_boundaries[!is.na(class_boundaries)]
          ord <- order(as.matrix(points)[, 1])
          num <- seq_along(ord)
          rank <- match(num, ord)
          res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
              ])
          min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
              3]))
          tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
              2], id = min_dist[, 3])
          enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 3], 
              FUN = min)
      }
      tibble::tibble(class = patches_class, value = enn$dist)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      np_class <- max(landscape_labeled, na.rm = TRUE)
      if (np_class == 1) {
          enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
          if (verbose) {
              warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                  call. = FALSE)
          }
      }
      else {
          class_boundaries <- get_boundaries(landscape_labeled, 
              directions = 4, as_NA = TRUE)[[1]]
          class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
          class_boundaries <- t(class_boundaries)
          points <- points[which(!is.na(class_boundaries)), ]
          points[, 3] <- class_boundaries[!is.na(class_boundaries)]
          ord <- order(as.matrix(points)[, 1])
          num <- seq_along(ord)
          rank <- match(num, ord)
          res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
              ])
          min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
              3]))
          tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
              2], id = min_dist[, 3])
          enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 3], 
              FUN = min)
      }
      tibble::tibble(class = patches_class, value = enn$dist)
  }))
  where 10: lsm_p_enn_calc(landscape, directions = directions, verbose = verbose, 
      points = points)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_l_enn_sd_calc, 
      directions = directions, verbose = verbose)
  where 13: lsm_l_enn_sd.RasterLayer(landscape)
  where 14 at testthat/test-lsm-l-enn-sd.R#3: lsm_l_enn_sd(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 81. Error: (unknown) (@test-lsm-l-enn-sd.R#3)  ------------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_l_enn_sd(landscape)
    2. landscapemetrics:::lsm_l_enn_sd.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_enn_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_frac_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_l_frac_cv_calc, 
      directions = directions)
  where 5: lsm_l_frac_cv.RasterLayer(landscape)
  where 6 at testthat/test-lsm-l-frac-cv.R#3: lsm_l_frac_cv(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 82. Error: (unknown) (@test-lsm-l-frac-cv.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_frac_cv(landscape)
   2. landscapemetrics:::lsm_l_frac_cv.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_frac_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_frac_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_l_frac_mn_calc, 
      directions = directions)
  where 5: lsm_l_frac_mn.RasterLayer(landscape)
  where 6 at testthat/test-lsm-l-frac-mn.R#3: lsm_l_frac_mn(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 83. Error: (unknown) (@test-lsm-l-frac-mn.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_frac_mn(landscape)
   2. landscapemetrics:::lsm_l_frac_mn.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_frac_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_frac_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_l_frac_sd_calc, 
      directions = directions)
  where 5: lsm_l_frac_sd.RasterLayer(landscape)
  where 6 at testthat/test-lsm-l-frac-sd.R#3: lsm_l_frac_sd(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 84. Error: (unknown) (@test-lsm-l-frac-sd.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_frac_sd(landscape)
   2. landscapemetrics:::lsm_l_frac_sd.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_frac_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_l_te_calc(landscape, count_boundary = TRUE, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_l_te_calc(landscape, count_boundary = TRUE, resolution = resolution)
  where 2: FUN(X[[i]], ...)
  where 3: lapply(X = raster::as.list(landscape), FUN = lsm_l_lsi_calc, 
      directions = directions)
  where 4: lsm_l_lsi.RasterLayer(landscape)
  where 5 at testthat/test-lsm-l-lsi.R#3: lsm_l_lsi(landscape)
  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(NULL, exprs, env)
  where 17: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 18: force(code)
  where 19: doWithOneRestart(return(expr), restart)
  where 20: withOneRestart(expr, restarts[[1L]])
  where 21: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 22: 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 23: FUN(X[[i]], ...)
  where 24: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 25: force(code)
  where 26: doWithOneRestart(return(expr), restart)
  where 27: withOneRestart(expr, restarts[[1L]])
  where 28: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 29: 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 30: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 31: 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 32: 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 33: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, count_boundary, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      if (count_boundary) {
          landscape <- pad_raster(landscape = landscape, pad_raster_value = max(landscape, 
              na.rm = TRUE) + 1, pad_raster_cells = 1, return_raster = FALSE)[[1]]
      }
      if (resolution_x == resolution_y) {
          neighbor_matrix <- rcpp_get_coocurrence_matrix(landscape, 
              directions = as.matrix(4))
          edge_total <- sum(neighbor_matrix[lower.tri(neighbor_matrix)]) * 
              resolution_x
      }
      else {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
          left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape, 
              directions = as.matrix(left_right_matrix))
          edge_left_right <- sum(left_right_neighbours[lower.tri(left_right_neighbours)]) * 
              resolution_x
          top_bottom_neighbours <- rcpp_get_coocurrence_matrix(raster::as.matrix(landscape), 
              directions = as.matrix(top_bottom_matrix))
          edge_top_bottom <- sum(top_bottom_neighbours[lower.tri(top_bottom_neighbours)]) * 
              resolution_y
          edge_total <- edge_left_right + edge_top_bottom
      }
      tibble::tibble(level = "landscape", class = as.integer(NA), 
          id = as.integer(NA), metric = "te", value = as.double(edge_total))
  }
  <bytecode: 0x8479560>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_l_te_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 85. Error: (unknown) (@test-lsm-l-lsi.R#3)  ---------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_lsi(landscape)
   2. landscapemetrics:::lsm_l_lsi.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_l_te_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: FUN(X[[i]], ...)
  where 3: lapply(X = raster::as.list(landscape), FUN = lsm_l_msidi_calc, 
      directions = directions)
  where 4: lsm_l_msidi.RasterLayer(landscape)
  where 5 at testthat/test-lsm-l-msidi.R#3: lsm_l_msidi(landscape)
  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(NULL, exprs, env)
  where 17: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 18: force(code)
  where 19: doWithOneRestart(return(expr), restart)
  where 20: withOneRestart(expr, restarts[[1L]])
  where 21: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 22: 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 23: FUN(X[[i]], ...)
  where 24: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 25: force(code)
  where 26: doWithOneRestart(return(expr), restart)
  where 27: withOneRestart(expr, restarts[[1L]])
  where 28: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 29: 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 30: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 31: 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 32: 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 33: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 86. Error: (unknown) (@test-lsm-l-msidi.R#3)  -------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_msidi(landscape)
   2. landscapemetrics:::lsm_l_msidi.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      patches_id <- 1:max(landscape_labeled, na.rm = TRUE)
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
          }
      }
      class_edge[class_edge == 1 | is.na(class_edge)] <- -999
      if (max(class_edge, na.rm = TRUE) == -999) {
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
      }
      else {
          patch_core <- get_patches(class_edge, class = 0, directions = directions, 
              return_raster = FALSE)[[1]]
          if (!consider_boundary) {
              patch_core <- patch_core[-c(1, nrow(patch_core)), 
                  -c(1, ncol(patch_core))]
              landscape_labeled <- landscape_labeled[-c(1, nrow(landscape_labeled)), 
                  -c(1, ncol(landscape_labeled))]
          }
          patch_core <- t(patch_core)
          landscape_labeled <- t(landscape_labeled)
          points <- data.frame(x = points[which(!is.na(patch_core)), 
              1], y = points[which(!is.na(patch_core)), 2], z = points[which(!is.na(patch_core)), 
              3])
          points$core_id <- patch_core[!is.na(patch_core)]
          points$patch_id <- landscape_labeled[!is.na(patch_core)]
          n_core_area <- table(unique(points[, c(4, 5)])[, 2])
          result <- c(rep(0, length(patches_id)))
          names(result) <- patches_id
          result[as.numeric(names(n_core_area))] <- n_core_area
      }
      tibble::tibble(class = patches_class, value = result)
  }))
  where 10: lsm_p_ncore_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, points = points)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_l_ndca_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_l_ndca.RasterLayer(landscape)
  where 14 at testthat/test-lsm-l-ndca.R#3: lsm_l_ndca(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 87. Error: (unknown) (@test-lsm-l-ndca.R#3)  --------------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_l_ndca(landscape)
    2. landscapemetrics:::lsm_l_ndca.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_ncore_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: FUN(X[[i]], ...)
  where 3: lapply(X = raster::as.list(landscape), FUN = lsm_l_pafrac_calc, 
      directions = directions, verbose = verbose)
  where 4: lsm_l_pafrac.RasterLayer(landscape)
  where 5 at testthat/test-lsm-l-pafrac.R#3: lsm_l_pafrac(landscape)
  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(NULL, exprs, env)
  where 17: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 18: force(code)
  where 19: doWithOneRestart(return(expr), restart)
  where 20: withOneRestart(expr, restarts[[1L]])
  where 21: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 22: 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 23: FUN(X[[i]], ...)
  where 24: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 25: force(code)
  where 26: doWithOneRestart(return(expr), restart)
  where 27: withOneRestart(expr, restarts[[1L]])
  where 28: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 29: 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 30: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 31: 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 32: 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 33: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 88. Error: (unknown) (@test-lsm-l-pafrac.R#3)  ------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_pafrac(landscape)
   2. landscapemetrics:::lsm_l_pafrac.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_para_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_l_para_cv_calc, 
      directions = directions)
  where 5: lsm_l_para_cv.RasterLayer(landscape)
  where 6 at testthat/test-lsm-l-para-cv.R#3: lsm_l_para_cv(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 89. Error: (unknown) (@test-lsm-l-para-cv.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_para_cv(landscape)
   2. landscapemetrics:::lsm_l_para_cv.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_para_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_para_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_l_para_mn_calc, 
      directions = directions)
  where 5: lsm_l_para_mn.RasterLayer(landscape)
  where 6 at testthat/test-lsm-l-para-mn.R#3: lsm_l_para_mn(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 90. Error: (unknown) (@test-lsm-l-para-mn.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_para_mn(landscape)
   2. landscapemetrics:::lsm_l_para_mn.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_para_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_para_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_l_para_sd_calc, 
      directions = directions)
  where 5: lsm_l_para_sd.RasterLayer(landscape)
  where 6 at testthat/test-lsm-l-para-sd.R#3: lsm_l_para_sd(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 91. Error: (unknown) (@test-lsm-l-para-sd.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_para_sd(landscape)
   2. landscapemetrics:::lsm_l_para_sd.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_para_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: FUN(X[[i]], ...)
  where 3: lapply(X = raster::as.list(landscape), FUN = lsm_l_pd_calc, directions = directions)
  where 4: lsm_l_pd.RasterLayer(landscape)
  where 5 at testthat/test-lsm-l-pd.R#3: lsm_l_pd(landscape)
  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(NULL, exprs, env)
  where 17: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 18: force(code)
  where 19: doWithOneRestart(return(expr), restart)
  where 20: withOneRestart(expr, restarts[[1L]])
  where 21: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 22: 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 23: FUN(X[[i]], ...)
  where 24: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 25: force(code)
  where 26: doWithOneRestart(return(expr), restart)
  where 27: withOneRestart(expr, restarts[[1L]])
  where 28: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 29: 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 30: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 31: 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 32: 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 33: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 92. Error: (unknown) (@test-lsm-l-pd.R#3)  ----------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_pd(landscape)
   2. landscapemetrics:::lsm_l_pd.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = -999, pad_raster_cells = 1, 
      return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = -999, pad_raster_cells = 1, 
      return_raster = FALSE)
  where 5: FUN(X[[i]], ...)
  where 6: lapply(X = raster::as.list(landscape), FUN = lsm_l_pladj_calc)
  where 7: lsm_l_pladj.RasterLayer(landscape)
  where 8 at testthat/test-lsm-l-pladj.R#3: lsm_l_pladj(landscape)
  where 9: eval(code, test_env)
  where 10: eval(code, test_env)
  where 11: 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 12: doTryCatch(return(expr), name, parentenv, handler)
  where 13: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 14: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 15: doTryCatch(return(expr), name, parentenv, handler)
  where 16: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 17: tryCatchList(expr, classes, parentenv, handlers)
  where 18: 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 19: test_code(NULL, exprs, env)
  where 20: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 21: force(code)
  where 22: doWithOneRestart(return(expr), restart)
  where 23: withOneRestart(expr, restarts[[1L]])
  where 24: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 25: 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 26: FUN(X[[i]], ...)
  where 27: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 28: force(code)
  where 29: doWithOneRestart(return(expr), restart)
  where 30: withOneRestart(expr, restarts[[1L]])
  where 31: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 32: 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 33: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 34: 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 35: 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 36: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 93. Error: (unknown) (@test-lsm-l-pladj.R#3)  -------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_pladj(landscape)
   2. landscapemetrics:::lsm_l_pladj.RasterLayer(landscape)
   3. base::lapply(X = raster::as.list(landscape), FUN = lsm_l_pladj_calc)
   4. landscapemetrics:::FUN(X[[i]], ...)
   6. landscapemetrics:::pad_raster.matrix(...)
   7. base::lapply(...)
   8. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_shape_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_l_shape_cv_calc, 
      directions = directions)
  where 5: lsm_l_shape_cv.RasterLayer(landscape)
  where 6 at testthat/test-lsm-l-shape-cv.R#3: lsm_l_shape_cv(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 94. Error: (unknown) (@test-lsm-l-shape-cv.R#3)  ----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_shape_cv(landscape)
   2. landscapemetrics:::lsm_l_shape_cv.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_shape_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_shape_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_l_shape_mn_calc, 
      directions = directions)
  where 5: lsm_l_shape_mn.RasterLayer(landscape)
  where 6 at testthat/test-lsm-l-shape-mn.R#3: lsm_l_shape_mn(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 95. Error: (unknown) (@test-lsm-l-shape-mn.R#3)  ----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_shape_mn(landscape)
   2. landscapemetrics:::lsm_l_shape_mn.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_shape_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_perim_calc(landscape, directions = directions, resolution = resolution)
  where 2: lsm_p_shape_calc(landscape, directions = directions, resolution = resolution)
  where 3: FUN(X[[i]], ...)
  where 4: lapply(X = raster::as.list(landscape), FUN = lsm_l_shape_sd_calc, 
      directions = directions)
  where 5: lsm_l_shape_sd.RasterLayer(landscape)
  where 6 at testthat/test-lsm-l-shape-sd.R#3: lsm_l_shape_sd(landscape)
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(NULL, exprs, env)
  where 18: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 19: force(code)
  where 20: doWithOneRestart(return(expr), restart)
  where 21: withOneRestart(expr, restarts[[1L]])
  where 22: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 23: 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 24: FUN(X[[i]], ...)
  where 25: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, 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 = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 31: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 32: 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 33: 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 34: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      resolution_x <- resolution[[1]]
      resolution_y <- resolution[[2]]
      classes <- get_unique_values(landscape)[[1]]
      if (!resolution_x == resolution_y) {
          top_bottom_matrix <- matrix(c(NA, NA, NA, 1, 0, 1, NA, 
              NA, NA), 3, 3, byrow = TRUE)
          left_right_matrix <- matrix(c(NA, 1, NA, NA, 0, NA, NA, 
              1, NA), 3, 3, byrow = TRUE)
      }
      perimeter_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          landscape_labeled <- pad_raster(landscape_labeled, pad_raster_value = NA, 
              pad_raster_cells = 1, return_raster = FALSE)[[1]]
          target_na <- which(is.na(landscape_labeled))
          landscape_labeled[target_na] <- -999
          if (resolution_x == resolution_y) {
              neighbour_matrix <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(4))
              perimeter_patch_ij <- neighbour_matrix[1, 2:ncol(neighbour_matrix)] * 
                  resolution_x
          }
          else {
              left_right_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(left_right_matrix))
              perimeter_patch_ij_left_right <- left_right_neighbours[1, 
                  2:ncol(left_right_neighbours)] * resolution_x
              top_bottom_neighbours <- rcpp_get_coocurrence_matrix(landscape_labeled, 
                  directions = as.matrix(top_bottom_matrix))
              perimeter_patch_ij_top_bottom <- top_bottom_neighbours[1, 
                  2:ncol(top_bottom_neighbours)] * resolution_y
              perimeter_patch_ij <- perimeter_patch_ij_top_bottom + 
                  perimeter_patch_ij_left_right
          }
          tibble::tibble(class = patches_class, value = perimeter_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(perimeter_patch$class), 
          id = as.integer(seq_len(nrow(perimeter_patch))), metric = "perim", 
          value = as.double(perimeter_patch$value))
  }
  <bytecode: 0x81645d8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_perim_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 96. Error: (unknown) (@test-lsm-l-shape-sd.R#3)  ----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_shape_sd(landscape)
   2. landscapemetrics:::lsm_l_shape_sd.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_shape_calc(...)
   6. landscapemetrics:::lsm_p_perim_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  }))
  where 10: lsm_p_core_calc(landscape, directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth, resolution = resolution)
  where 11: FUN(X[[i]], ...)
  where 12: lapply(X = raster::as.list(landscape), FUN = lsm_l_tca_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 13: lsm_l_tca.RasterLayer(landscape)
  where 14 at testthat/test-lsm-l-tca.R#3: lsm_l_tca(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 97. Error: (unknown) (@test-lsm-l-tca.R#3)  ---------------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_l_tca(landscape)
    2. landscapemetrics:::lsm_l_tca.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    5. landscapemetrics:::lsm_p_core_calc(...)
    7. base::lapply(...)
    8. landscapemetrics:::FUN(X[[i]], ...)
   10. landscapemetrics:::get_boundaries.matrix(...)
   12. landscapemetrics:::pad_raster.matrix(...)
   13. base::lapply(...)
   14. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape = landscape, pad_raster_value = max(landscape, 
      na.rm = TRUE) + 1, pad_raster_cells = 1, return_raster = FALSE)
  where 4: pad_raster(landscape = landscape, pad_raster_value = max(landscape, 
      na.rm = TRUE) + 1, pad_raster_cells = 1, return_raster = FALSE)
  where 5: FUN(X[[i]], ...)
  where 6: lapply(X = raster::as.list(landscape), FUN = lsm_l_te_calc, count_boundary = count_boundary)
  where 7: lsm_l_te.RasterLayer(landscape, count_boundary = TRUE)
  where 8 at testthat/test-lsm-l-te.R#26: lsm_l_te(landscape, count_boundary = TRUE)
  where 9: eval(code, test_env)
  where 10: eval(code, test_env)
  where 11: 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 12: doTryCatch(return(expr), name, parentenv, handler)
  where 13: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 14: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 15: doTryCatch(return(expr), name, parentenv, handler)
  where 16: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 17: tryCatchList(expr, classes, parentenv, handlers)
  where 18: 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 19: test_code(desc, code, env = parent.frame())
  where 20 at testthat/test-lsm-l-te.R#25: test_that("lsm_l_te option count_boundary is working", {
      te_with_boundary <- lsm_l_te(landscape, count_boundary = TRUE)
      te_without_boundary <- lsm_l_te(landscape, count_boundary = FALSE)
      expect_lt(te_without_boundary$value, te_with_boundary$value)
  })
  where 21: eval(code, test_env)
  where 22: eval(code, test_env)
  where 23: 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 24: doTryCatch(return(expr), name, parentenv, handler)
  where 25: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 26: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 27: doTryCatch(return(expr), name, parentenv, handler)
  where 28: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 29: tryCatchList(expr, classes, parentenv, handlers)
  where 30: 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 31: test_code(NULL, exprs, env)
  where 32: source_file(path, new.env(parent = env), chdir = TRUE, 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 = 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 38: FUN(X[[i]], ...)
  where 39: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 40: force(code)
  where 41: doWithOneRestart(return(expr), restart)
  where 42: withOneRestart(expr, restarts[[1L]])
  where 43: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 44: 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 45: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 46: 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 47: 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 48: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 98. Error: lsm_l_te option count_boundary is working (@test-lsm-l-te.R#26)  -
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_l_te(landscape, count_boundary = TRUE)
   2. landscapemetrics:::lsm_l_te.RasterLayer(landscape, count_boundary = TRUE)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   6. landscapemetrics:::pad_raster.matrix(...)
   7. base::lapply(...)
   8. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape = landscape, directions = directions, 
      resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape = landscape, directions = directions, 
      resolution = resolution)
  where 2: FUN(X[[i]], ...)
  where 3: lapply(X = raster::as.list(landscape), FUN = lsm_p_cai_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 4: lsm_p_cai.RasterLayer(landscape)
  where 5 at testthat/test-lsm-p-cai.R#3: lsm_p_cai(landscape)
  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(NULL, exprs, env)
  where 17: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 18: force(code)
  where 19: doWithOneRestart(return(expr), restart)
  where 20: withOneRestart(expr, restarts[[1L]])
  where 21: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 22: 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 23: FUN(X[[i]], ...)
  where 24: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 25: force(code)
  where 26: doWithOneRestart(return(expr), restart)
  where 27: withOneRestart(expr, restarts[[1L]])
  where 28: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 29: 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 30: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 31: 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 32: 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 33: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 99. Error: (unknown) (@test-lsm-p-cai.R#3)  ---------------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_p_cai(landscape)
   2. landscapemetrics:::lsm_p_cai.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: lsm_p_area_calc(landscape, directions = directions, resolution = resolution)
  where 2: FUN(X[[i]], ...)
  where 3: lapply(X = raster::as.list(landscape), FUN = lsm_p_circle_calc, 
      directions = directions)
  where 4: lsm_p_circle.RasterLayer(landscape)
  where 5 at testthat/test-lsm-p-circle.R#3: lsm_p_circle(landscape)
  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(NULL, exprs, env)
  where 17: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 18: force(code)
  where 19: doWithOneRestart(return(expr), restart)
  where 20: withOneRestart(expr, restarts[[1L]])
  where 21: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 22: 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 23: FUN(X[[i]], ...)
  where 24: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 25: force(code)
  where 26: doWithOneRestart(return(expr), restart)
  where 27: withOneRestart(expr, restarts[[1L]])
  where 28: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 29: 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 30: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 31: 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 32: 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 33: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x84af298>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 100. Error: (unknown) (@test-lsm-p-circle.R#3)  -----------------------------
  the condition has length > 1
  Backtrace:
   1. landscapemetrics::lsm_p_circle(landscape)
   2. landscapemetrics:::lsm_p_circle.RasterLayer(landscape)
   3. base::lapply(...)
   4. landscapemetrics:::FUN(X[[i]], ...)
   5. landscapemetrics:::lsm_p_area_calc(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 6: get_boundaries(landscape_labeled, directions = 4, consider_boundary = consider_boundary)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      class_edge <- get_boundaries(landscape_labeled, directions = 4, 
          consider_boundary = consider_boundary)[[1]]
      cells_edge_patch <- table(landscape_labeled[class_edge == 
          1])
      if (edge_depth > 1) {
          for (i in seq_len(edge_depth - 1)) {
              class_edge[class_edge == 1] <- NA
              class_edge <- get_boundaries(class_edge, directions = 4, 
                  consider_boundary = consider_boundary)[[1]]
              cells_edge_patch <- cells_edge_patch + tabulate(landscape_labeled[class_edge == 
                  1], nbins = length(cells_edge_patch))
          }
      }
      cells_patch <- table(landscape_labeled)
      if (dim(cells_edge_patch) == 0) {
          cells_edge_patch <- 0
      }
      core_area <- (cells_patch - cells_edge_patch) * prod(resolution)/10000
      tibble::tibble(class = patches_class, value = core_area)
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = lsm_p_core_calc, 
      directions = directions, consider_boundary = consider_boundary, 
      edge_depth = edge_depth)
  where 12: lsm_p_core.RasterLayer(landscape)
  where 13 at testthat/test-lsm-p-core.R#3: lsm_p_core(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 101. Error: (unknown) (@test-lsm-p-core.R#3)  -------------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_p_core(landscape)
    2. landscapemetrics:::lsm_p_core.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. base::lapply(...)
    7. landscapemetrics:::FUN(X[[i]], ...)
    9. landscapemetrics:::get_boundaries.matrix(...)
   11. landscapemetrics:::pad_raster.matrix(...)
   12. base::lapply(...)
   13. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  FUN(X[[i]], ...)
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: FUN(X[[i]], ...)
  where 2: lapply(X = list(landscape), FUN = pad_raster_internal, pad_raster_value = pad_raster_value, 
      pad_raster_cells = pad_raster_cells, global = global)
  where 3: pad_raster.matrix(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 4: pad_raster(landscape, pad_raster_value = NA, pad_raster_cells = 1, 
      global = FALSE, return_raster = FALSE)
  where 5: get_boundaries.matrix(landscape_labeled, directions = 4, as_NA = TRUE)
  where 6: get_boundaries(landscape_labeled, directions = 4, as_NA = TRUE)
  where 7: FUN(X[[i]], ...)
  where 8: lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      np_class <- max(landscape_labeled, na.rm = TRUE)
      if (np_class == 1) {
          enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
          if (verbose) {
              warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                  call. = FALSE)
          }
      }
      else {
          class_boundaries <- get_boundaries(landscape_labeled, 
              directions = 4, as_NA = TRUE)[[1]]
          class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
          class_boundaries <- t(class_boundaries)
          points <- points[which(!is.na(class_boundaries)), ]
          points[, 3] <- class_boundaries[!is.na(class_boundaries)]
          ord <- order(as.matrix(points)[, 1])
          num <- seq_along(ord)
          rank <- match(num, ord)
          res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
              ])
          min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
              3]))
          tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
              2], id = min_dist[, 3])
          enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 3], 
              FUN = min)
      }
      tibble::tibble(class = patches_class, value = enn$dist)
  })
  where 9: do.call(rbind, lapply(classes, function(patches_class) {
      landscape_labeled <- get_patches(landscape, class = patches_class, 
          directions = directions, return_raster = FALSE)[[1]]
      np_class <- max(landscape_labeled, na.rm = TRUE)
      if (np_class == 1) {
          enn <- tibble::tibble(class = patches_class, dist = as.double(NA))
          if (verbose) {
              warning(paste0("Class ", patches_class, ": ENN = NA for class with only 1 patch"), 
                  call. = FALSE)
          }
      }
      else {
          class_boundaries <- get_boundaries(landscape_labeled, 
              directions = 4, as_NA = TRUE)[[1]]
          class_boundaries[!is.na(class_boundaries)] <- landscape_labeled[!is.na(class_boundaries)]
          class_boundaries <- t(class_boundaries)
          points <- points[which(!is.na(class_boundaries)), ]
          points[, 3] <- class_boundaries[!is.na(class_boundaries)]
          ord <- order(as.matrix(points)[, 1])
          num <- seq_along(ord)
          rank <- match(num, ord)
          res <- rcpp_get_nearest_neighbor(as.matrix(points)[ord, 
              ])
          min_dist <- unname(cbind(num, res[rank], as.matrix(points)[, 
              3]))
          tbl <- tibble::tibble(cell = min_dist[, 1], dist = min_dist[, 
              2], id = min_dist[, 3])
          enn <- stats::aggregate(x = tbl[, 2], by = tbl[, 3], 
              FUN = min)
      }
      tibble::tibble(class = patches_class, value = enn$dist)
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = lsm_p_enn_calc, 
      directions = directions, verbose = verbose)
  where 12: lsm_p_enn.RasterLayer(landscape)
  where 13 at testthat/test-lsm-p-enn.R#3: lsm_p_enn(landscape)
  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("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, pad_raster_value, pad_raster_cells, global) 
  {
      if (class(landscape) != "matrix") {
          landscape <- raster::as.matrix(landscape)
      }
      y_direction <- matrix(rep(x = pad_raster_value, times = ncol(landscape) * 
          pad_raster_cells), nrow = pad_raster_cells)
      landscape_padded <- rbind(y_direction, landscape, y_direction, 
          deparse.level = 0)
      x_direction <- matrix(rep(x = pad_raster_value, times = nrow(landscape_padded) * 
          pad_raster_cells), ncol = pad_raster_cells)
      landscape_padded <- cbind(x_direction, landscape_padded, 
          x_direction, deparse.level = 0)
      if (global) {
          landscape_padded[is.na(landscape_padded)] <- pad_raster_value
      }
      return(landscape_padded)
  }
  <bytecode: 0x83c16e8>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function pad_raster_internal in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 102. Error: (unknown) (@test-lsm-p-enn.R#3)  --------------------------------
  the condition has length > 1
  Backtrace:
    1. landscapemetrics::lsm_p_enn(landscape)
    2. landscapemetrics:::lsm_p_enn.RasterLayer(landscape)
    3. base::lapply(...)
    4. landscapemetrics:::FUN(X[[i]], ...)
    6. base::lapply(...)
    7. landscapemetrics:::FUN(X[[i]], ...)
    9. landscapemetrics:::get_boundaries.matrix(...)
   11. landscapemetrics:::pad_raster.matrix(...)
   12. base::lapply(...)
   13. landscapemetrics:::FUN(X[[i]], ...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  lsm_p_perim_calc(landscape, directions