R Under development (unstable) (2024-02-08 r85876 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > expect_equal <- function(x, y) { + stopifnot(isTRUE(all.equal(x, y))) + } > > expect_equal_pairs <- function(x, y) { + setkey(pairs_ref, .x, .y) + setkey(pairs_loc, .x, .y) + expect_equal(pairs_ref$.x, pairs_loc$.x) + expect_equal(pairs_ref$.y, pairs_loc$.y) + } > > expect_equal_pairs <- function(x, y) { + setkey(pairs_ref, .x, .y) + setkey(pairs_loc, .x, .y) + expect_equal(names(x), names(y)) + for (col in names(x)) + expect_equal(x[[col]], y[[col]]) + } > > library(reclin2) Loading required package: data.table > library(parallel) > > x <- data.table(a = c(1,1,2,2), b = c(1,2,1,2)) > y <- data.table(a = c(3,3,2,2), b = c(1,2,1,2)) > > > cl <- makeCluster(2) > > set.seed(103) > pairs <- cluster_pair(cl, x, y) > pairs_ref <- pair(x, y) > pairs_loc <- cluster_collect(pairs) > pairs_ref <- compare_pairs(pairs_ref, c("a", "b")) > pairs_loc <- compare_pairs(pairs_loc, c("a", "b")) > expect_equal_pairs(pairs_ref, pairs_loc) > # The compare_pairs was added to fix a bug where the x after > # cluster_colled was not longer in the correct order; issue #2 > > set.seed(103) > pairs <- cluster_pair(cl, x, deduplication = TRUE) > pairs_ref <- pair(x, deduplication = TRUE) > pairs_loc <- cluster_collect(pairs) > pairs_ref <- compare_pairs(pairs_ref, c("a", "b")) > pairs_loc <- compare_pairs(pairs_loc, c("a", "b")) > expect_equal_pairs(pairs_ref, pairs_loc) > > stopCluster(cl) > > > proc.time() user system elapsed 0.42 0.18 1.15