We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 07eed59 commit a0c6958Copy full SHA for a0c6958
2 files changed
R/graph_wrappers.R
@@ -556,18 +556,19 @@ setMethod(
556
poly2nb = poly2nb
557
)
558
if (length(sample_id) == 1L) {
559
- out <- .comp_graph_sample(
+ tryCatch(out <- .comp_graph_sample(
560
x, sample_id, type, MARGIN, method,
561
dist_type, args, extra_args_use, glist,
562
style, zero.policy, alpha, dmax, fun_use, return_sf
563
- )
+ ), error = function(e) stop(method, ": ", e$message, call. = FALSE))
564
+
565
} else {
566
out <- lapply(sample_id, function(s) {
- .comp_graph_sample(
567
+ tryCatch(.comp_graph_sample(
568
x, s, type, MARGIN, method, dist_type,
569
args, extra_args_use, glist, style,
570
zero.policy, alpha, dmax, fun_use, return_sf
571
572
})
573
names(out) <- sample_id
574
}
tests/testthat/test-graph_wrappers.R
@@ -172,3 +172,12 @@ test_that("Correct Visium HD graph", {
172
g <- findVisiumHDGraph(sfe)
173
expect_s3_class(g, "listw")
174
175
176
+test_that("Show method name in error message", {
177
+ mat <- matrix(rnorm(9), 3, 3)
178
+ # Get duplicated coordinates
179
+ coords <- cbind(c(1,2,1), c(1,2,1))
180
+ sfe <- SpatialFeatureExperiment(assays = list(counts = mat),
181
+ spatialCoords = coords)
182
+ expect_error(findSpatialNeighbors(sfe), "tri2nb")
183
+})
0 commit comments