From 7e935ec3dd02e3de7c6eb285fdd94b55015e50a8 Mon Sep 17 00:00:00 2001 From: Benjamin Elbers Date: Wed, 20 Sep 2023 14:59:54 +0200 Subject: [PATCH] use rcpp interruption --- R/compression.R | 9 --------- src/compression.cpp | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/R/compression.R b/R/compression.R index 0df212e..d8c3c5c 100644 --- a/R/compression.R +++ b/R/compression.R @@ -62,9 +62,6 @@ compress <- function(data, group, unit, weight = NULL, } iterations <- as.data.table(res) - if (nrow(iterations) == 0) { - stop("user interruption") - } initial_M <- mutual_total(d, group, unit, weight = "freq")[["est"]][1] iterations[, pct_M := M / initial_M] @@ -343,14 +340,8 @@ midcache.dendrogram <- function(x) { repeat { if (!stats::is.leaf(d)) { k <- length(d) - if (k < 1) { - stop("dendrogram node with non-positive #{branches}") - } depth <- depth + 1L kk[depth] <- k - if (storage.mode(jj) != storage.mode(kk)) { - storage.mode(jj) <- storage.mode(kk) - } dd[[depth]] <- d d <- d[[jj[depth] <- 1L]] next diff --git a/src/compression.cpp b/src/compression.cpp index 3b17a49..a59b134 100644 --- a/src/compression.cpp +++ b/src/compression.cpp @@ -229,7 +229,7 @@ List compress_compute_cpp( while (neighbors.size() > 0) { if (Progress::check_abort()) - return List::create(); + throw Rcpp::exception("user interruption"); // find smallest reduction double min_reduction = 10000;