-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestsM.R
89 lines (78 loc) · 2.79 KB
/
testsM.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#'
#' Header for all (concatenated) test files
#'
#' Require spatstat.explore
#' Obtain environment variable controlling tests.
#'
#' $Revision: 1.5 $ $Date: 2020/04/30 05:31:37 $
require(spatstat.explore)
FULLTEST <- (nchar(Sys.getenv("SPATSTAT_TEST", unset="")) > 0)
ALWAYS <- TRUE
cat(paste("--------- Executing",
if(FULLTEST) "** ALL **" else "**RESTRICTED** subset of",
"test code -----------\n"))
##
## tests/markcor.R
##
## Tests of mark correlation code (etc)
##
## $Revision: 1.7 $ $Date: 2020/11/25 01:23:32 $
local({
if(ALWAYS) {
## check.testfun checks equality of functions
## and is liable to break if the behaviour of all.equal is changed
fe <- function(m1, m2) {m1 == m2}
fm <- function(m1, m2) {m1 * m2}
fs <- function(m1, m2) {sqrt(m1)}
if(check.testfun(fe, X=amacrine)$ftype != "equ")
warning("check.testfun fails to recognise mark equality function")
if(check.testfun(fm, X=longleaf)$ftype != "mul")
warning("check.testfun fails to recognise mark product function")
check.testfun(fs, X=longleaf)
check.testfun("mul")
check.testfun("equ")
}
if(FULLTEST) {
## test all is well in Kmark -> Kinhom
MA <- Kmark(amacrine,function(m1,m2){m1==m2})
set.seed(42)
AR <- rlabel(amacrine)
MR <- Kmark(AR,function(m1,m2){m1==m2})
if(isTRUE(all.equal(MA,MR)))
stop("Kmark unexpectedly ignores marks")
## cover code blocks in markcorr()
X <- runifpoint(100) %mark% runif(100)
Y <- X %mark% data.frame(u=runif(100), v=runif(100))
ww <- runif(100)
fone <- function(x) { x/2 }
ffff <- function(x,y) { fone(x) * fone(y) }
aa <- markcorr(Y)
bb <- markcorr(Y, ffff, weights=ww, normalise=TRUE)
bb <- markcorr(Y, ffff, weights=ww, normalise=FALSE)
bb <- markcorr(Y, f1=fone, weights=ww, normalise=TRUE)
bb <- markcorr(Y, f1=fone, weights=ww, normalise=FALSE)
## markcrosscorr
a <- markcrosscorr(betacells, normalise=FALSE)
if(require(sm)) {
b <- markcrosscorr(betacells, method="sm")
}
## Vmark with normalisation
v <- Vmark(spruces, normalise=TRUE)
v <- Vmark(finpines, normalise=TRUE)
}
})
#' tests/mctests.R
#' Monte Carlo tests
#' (mad.test, dclf.test, envelopeTest, hasenvelope)
#' $Revision: 1.5 $ $Date: 2022/05/23 04:09:49 $
local({
if(FULLTEST) {
envelopeTest(cells, Lest, exponent=1, nsim=9, savepatterns=TRUE)
(a3 <- envelopeTest(cells, Lest, exponent=3, nsim=9, savepatterns=TRUE))
envelopeTest(a3, Lest, exponent=3, nsim=9, alternative="less")
envelopeTest(redwood, Lest, exponent=1, nsim=19,
rinterval=c(0, 0.1), alternative="greater", clamp=TRUE)
envelopeTest(redwood, pcf, exponent=Inf, nsim=19,
rinterval=c(0, 0.1), alternative="greater", clamp=TRUE)
}
})