R Under development (unstable) (2025-09-04 r88794 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 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. > library(reclin2) > library(data.table) > source("helpers.R") > > pairs <- data.table( + .x = c(3,3,1,2,3,2), + .y = c(4,5,1,2,1,3), + score = c(1,5,10,5,4,1) + ) > class(pairs) <- c("pairs", class(pairs)) > > t <- select_greedy(pairs, "select", "score") > expect_equal(t$select, c(FALSE, TRUE, TRUE, TRUE, FALSE, FALSE)) > > t <- select_greedy(pairs, "select", "score", threshold = 20) > expect_equal(t$select, c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE)) > > t <- select_greedy(pairs, "select", "score", threshold = 10) > expect_equal(t$select, c(FALSE, FALSE, TRUE, FALSE, FALSE, FALSE)) > > # Test empty set pairs; regression test > t <- select_greedy(pairs[FALSE,], "select", "score", threshold = 10) > expect_equal(t$select, logical(0)) > > > > # Deduplication > pairs <- data.table( + .x = c(1,1,2,1), + .y = c(2,3,3,4), + score = c(3,2,4,0) + ) > class(pairs) <- c("pairs", class(pairs)) > # Incorrect: > t <- select_greedy(pairs, "select", "score") > expect_equal(t$select, c(TRUE, FALSE, TRUE, FALSE)) > attr(pairs, "deduplication") <- TRUE > t <- select_greedy(pairs, "select", "score") > t Total number of pairs: 4 pairs .x .y score select 1: 1 2 3 FALSE 2: 1 3 2 FALSE 3: 2 3 4 TRUE 4: 1 4 0 TRUE > expect_equal(t$select, c(FALSE, FALSE, TRUE, TRUE)) > > > proc.time() user system elapsed 0.34 0.04 0.32