From 54598ee2dfa91056f3d8df8423a89c9d4d42ddd0 Mon Sep 17 00:00:00 2001 From: Siyuan Luo Date: Tue, 14 Jan 2025 22:33:21 +0100 Subject: [PATCH] update test --- tests/testthat/test-spatial.R | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/testthat/test-spatial.R b/tests/testthat/test-spatial.R index e8eb725..4f2cd98 100644 --- a/tests/testthat/test-spatial.R +++ b/tests/testthat/test-spatial.R @@ -2,28 +2,31 @@ data(sp_toys) d <- sp_toys test_that("Internal spatial metrics work", { - sm <- getSpatialInternalMetrics(d$label, d[,seq_len(2)], level="dataset") + sm <- getSpatialInternalMetrics(labels=d$label, location=d[,seq_len(2)], + level="dataset") expect_true(all(!is.na(as.matrix(sm)))) - sm <- getSpatialInternalMetrics(d$label, d[,seq_len(2)], level="class") - sm2 <- getSpatialInternalMetrics(d$label, d[,seq_len(2)], level="element", + sm <- getSpatialInternalMetrics(labels=d$label, location=d[,seq_len(2)], + level="class") + sm2 <- getSpatialInternalMetrics(labels=d$label, location=d[,seq_len(2)], + level="element", metrics=c("PAS","ELSA")) medElsa <- sapply(split(sm2$ELSA, sm2$PAS), median) expect_true(all(medElsa[1]<0.2 & medElsa[2]>0.5)) }) test_that("External spatial metrics work", { - sm <- getSpatialExternalMetrics(d$label, d$p1, d[,seq_len(2)], - level="dataset") + sm <- getSpatialExternalMetrics(true=d$label, pred=d$p1, + location=d[,seq_len(2)], level="dataset") expect_true(all(!is.na(as.matrix(sm)))) - sm <- getSpatialExternalMetrics(d$label, d$p1, d[,seq_len(2)], - level="class") + sm <- getSpatialExternalMetrics(true=d$label, pred=d$p1, + location=d[,seq_len(2)], level="class") expect_true(sm$SpatialAWH[3]==1) expect_true(sm$SpatialAWC[2]==1) - sm2 <- getSpatialExternalMetrics(d$label, d$p1, d[,seq_len(2)], - level="element", + sm2 <- getSpatialExternalMetrics(true=d$label, pred=d$p1, + location=d[,seq_len(2)], level="element", metrics=c("SpatialSPC","SpatialNPC")) - sm2 <- getSpatialExternalMetrics(d$label, d$p1, d[,seq_len(2)], - level="element", + sm2 <- getSpatialExternalMetrics(true=d$label, pred=d$p1, + location=d[,seq_len(2)], level="element", metrics=c("SpatialSPC"), useNegatives=FALSE) medSPC <- sapply(split(sm2$SpatialSPC, d$label!=d$p1), median) expect_true(all(medSPC[1]>0.8 & medSPC[2]<0.3))