Running ‘testthat.R’ [13s/16s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > test_check("spNetwork")
  Loading required package: spNetwork
  [1] "checking inputs ..."
  [1] "prior data preparation ..."
  [1] "start calculating the kernel values for the adaptive bandwidth..."
  [1] "    quadra 1/1"
  [1] "    build graph ..."
  [1] "        calculating NKDE values ..."
  0%   10   20   30   40   50   60   70   80   90   100%
  [----|----|----|----|----|----|----|----|----|----|
  **************************************************|
  *************************[1] "Splitting the data with the spatial grid ..."
  [1] "start calculating the kernel values ..."
  [1] "    quadra 1/1"
  [1] "    build graph ..."
  [1] "        calculating NKDE values ..."
  0%   10   20   30   40   50   60   70   80   90   100%
  [----|----|----|----|----|----|----|----|----|----|
  **************************************************|
  *************************[1] "combining the results ..."
  [1] "checking inputs ..."
  [1] "prior data preparation ..."
  [1] "calculating the local bandwidth ..."
  [1] "start calculating the kernel values for the adaptive bandwidth..."
  [1] "starting the kernel calculations ..."
  0%   10   20   30   40   50   60   70   80   90   100%
  [----|----|----|----|----|----|----|----|----|----|
  **************************************************|
  *************************[1] "starting the kernel calculations ..."
  0%   10   20   30   40   50   60   70   80   90   100%
  [----|----|----|----|----|----|----|----|----|----|
  **************************************************|
  *************************[1] "combining the results ..."
  [1] "checking inputs ..."
  [1] "prior data preparation ..."
  [1] "start calculating the kernel values for the adaptive bandwidth..."
  [1] "start calculating the kernel values ..."
  [1] "    quadra 1/1"
  [1] "    build graph ..."
  [1] "        calculating NKDE values ..."
  0%   10   20   30   40   50   60   70   80   90   100%
  [----|----|----|----|----|----|----|----|----|----|
  **************************************************|
  *************************[1] "combining the results ..."
  [1] "checking inputs ..."
  [1] "prior data preparation ..."
  [1] "start calculating the kernel values for the adaptive bandwidth..."
  [1] "starting the kernel calculations ..."
  0%   10   20   30   40   50   60   70   80   90   100%
  [----|----|----|----|----|----|----|----|----|----|
  **************************************************|
  *************************[1] "    build graph ..."
  [1] "        calculating NKDE values ..."
  [1] "combining the results ..."
  [1] "generating the starting points"
  [1] "snapping the points to the lines (only once)"
  [1] "starting the network part"
  [1] "working on quadra : 1/1"
  [1] "adding the points as vertices to nearest lines"
  [1] "splitting the lines for the network"
  [1] "generating the network"
  [1] "calculating the distances on the network"
  [1] "building the final listw object"
  [1] "finally generating the listw object ..."
  [1] "checking inputs ..."
  [1] "prior data preparation ..."
  [1] "Calculating the correction factor if required"
  [1] "Splittig the dataset within the grid ..."
  [1] "start calculating the CV values ..."
  
    |                                                                            
    |                                                                      |   0%
    |                                                                            
    |======================================================================| 100%[1] "checking inputs ..."
  [1] "prior data preparation ..."
  [1] "Calculating the correction factor if required"
  [1] "start calculating the CV values ..."
  
    |                                                                            
    |                                                                      |   0%
   *** caught segfault ***
  address 0x30, cause 'memory not mapped'
  
  Traceback:
   1: nrow(coord_list[[e]])
   2: FUN(X[[i]], ...)
   3: lapply(1:length(coord_list), function(e) {    rep(e, nrow(coord_list[[e]]))})
   4: do.call(c, lapply(1:length(coord_list), function(e) {    rep(e, nrow(coord_list[[e]]))}))
   5: list_coordinates_as_lines(new_lines_list, crs = st_crs(lines))
   6: split_lines_at_vertex(sel_lines, sel_events, sel_events$nearest_line_id,     tol)
   7: FUN(X[[i]], ...)
   8: lapply(1:nrow(grid), function(i) {    square <- grid[i, ]    sel_samples <- spatial_request(square, tree_samples, samples)    if (nrow(sel_samples) == 0) {        return(NULL)    }    buff <- st_buffer(square, dist = bw)    buff2 <- st_buffer(square, dist = (bw + 0.5 * bw))    sel_events <- spatial_request(buff, tree_events, events)    sel_lines <- spatial_request(buff2, tree_lines, lines)    sel_lines$oid <- 1:nrow(sel_lines)    if (nrow(sel_events) == 0) {        new_lines <- sel_lines    }    else {        a <- nrow(sel_events)        b <- nrow(sel_lines)        x <- a * b        sel_events <- snapPointsToLines2(sel_events, sel_lines,             idField = "oid", snap_dist = bw)        if (split_all) {            new_lines <- add_vertices_lines(sel_lines, sel_events,                 sel_events$nearest_line_id, tol)        }        else {            new_lines <- split_lines_at_vertex(sel_lines, sel_events,                 sel_events$nearest_line_id, tol)        }    }    if (split_all) {        new_lines <- simple_lines(new_lines)    }    new_lines$length <- as.numeric(st_length(new_lines))    new_lines <- subset(new_lines, new_lines$length > 0)    new_lines <- remove_loop_lines(new_lines, digits)    new_lines$oid <- 1:nrow(new_lines)    new_lines <- new_lines[c("length", "oid")]    return(list(samples = sel_samples, events = sel_events, lines = new_lines))})
   9: split_by_grid(grid, events, events_loc, lines, max_bw, tol, digits,     split_all = FALSE)
  10: bw_cv_likelihood_calc.mc(c(200, 400), 100, lines, events, rep(1,     nrow(events)), "scaled gaussian", "discontinuous", diggle_correction = FALSE,     study_area = NULL, max_depth = 8, digits = 2, tol = 0.1,     agg = 5, sparse = TRUE, grid_shape = c(2, 2), sub_sample = 1,     verbose = FALSE, check = TRUE)
  11: eval(code, test_env)
  12: eval(code, test_env)
  13: withCallingHandlers({    eval(code, test_env)    if (!handled && !is.null(test)) {        skip_empty()    }}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,     message = handle_message, error = handle_error)
  14: doTryCatch(return(expr), name, parentenv, handler)
  15: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  16: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  17: doTryCatch(return(expr), name, parentenv, handler)
  18: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),     names[nh], parentenv, handlers[[nh]])
  19: tryCatchList(expr, classes, parentenv, handlers)
  20: 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) {    })
  21: test_code(desc, code, env = parent.frame(), default_reporter = local_interactive_reporter())
  22: test_that("Testing that bw selection by cv-likelihood gives the same score in single and multicore",     {        data(mtl_network)        data(bike_accidents)        case1 <- bike_accidents[25, ]        buff <- st_buffer(case1, dist = 1000)        inter_idx1 <- sf::st_intersects(bike_accidents, buff,             sparse = FALSE)[, 1]        inter_idx2 <- sf::st_intersects(mtl_network, buff, sparse = FALSE)[,             1]        events <- subset(bike_accidents, inter_idx1)        lines <- subset(mtl_network, inter_idx2)        future::plan(future::multisession(workers = 2))        cv_scores.mc <- bw_cv_likelihood_calc.mc(c(200, 400),             100, lines, events, rep(1, nrow(events)), "scaled gaussian",             "discontinuous", diggle_correction = FALSE, study_area = NULL,             max_depth = 8, digits = 2, tol = 0.1, agg = 5, sparse = TRUE,             grid_shape = c(2, 2), sub_sample = 1, verbose = FALSE,             check = TRUE)        cv_scores.mc2 <- bw_cv_likelihood_calc.mc(c(200, 400),             100, lines, events, rep(1, nrow(events)), "scaled gaussian",             "discontinuous", diggle_correction = FALSE, study_area = NULL,             max_depth = 8, digits = 2, tol = 0.1, agg = 5, sparse = TRUE,             grid_shape = c(2, 2), sub_sample = 1, verbose = TRUE,             check = TRUE)        cv_scores <- bw_cv_likelihood_calc(bw_range = c(200,             400), bw_step = 100, lines = lines, events = events,             w = rep(1, nrow(events)), kernel_name = "scaled gaussian",             method = "discontinuous", diggle_correction = FALSE,             study_area = NULL, max_depth = 8, digits = 2, tol = 0.1,             agg = 5, sparse = TRUE, grid_shape = c(2, 2), sub_sample = 1,             verbose = TRUE, check = TRUE)        test1 <- cv_scores == cv_scores.mc        test2 <- cv_scores.mc2 == cv_scores.mc        expect_false(any(!test1) | any(!test2))    })
  23: eval(code, test_env)
  24: eval(code, test_env)
  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)
  26: doTryCatch(return(expr), name, parentenv, handler)
  27: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  28: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  29: doTryCatch(return(expr), name, parentenv, handler)
  30: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),     names[nh], parentenv, handlers[[nh]])
  31: tryCatchList(expr, classes, parentenv, handlers)
  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) {    })
  33: test_code(test = NULL, code = exprs, env = env, default_reporter = StopReporter$new())
  34: source_file(path, env(env), wrap = wrap)
  35: FUN(X[[i]], ...)
  36: lapply(test_paths, test_one_file, env = env, wrap = wrap)
  37: doTryCatch(return(expr), name, parentenv, handler)
  38: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  39: tryCatchList(expr, classes, parentenv, handlers)
  40: tryCatch(code, testthat_abort_reporter = function(cnd) {    cat(conditionMessage(cnd), "\n")    NULL})
  41: with_reporter(reporters$multi, lapply(test_paths, test_one_file,     env = env, wrap = wrap))
  42: test_files_serial(test_dir = test_dir, test_package = test_package,     test_paths = test_paths, load_helpers = load_helpers, reporter = reporter,     env = env, stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,     wrap = wrap, load_package = load_package)
  43: test_files(test_dir = path, test_paths = test_paths, test_package = package,     reporter = reporter, load_helpers = load_helpers, env = env,     stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,     wrap = wrap, load_package = load_package, parallel = parallel)
  44: test_dir("testthat", package = package, reporter = reporter,     ..., load_package = "installed")
  45: test_check("spNetwork")
  An irrecoverable exception occurred. R is aborting now ...
  Segmentation fault