# NOT RUN {
##
## 1. trim a simple matrix
##
tst1 <- matrix(.Machine$double.eps, 3, 3,
dimnames=list(letters[1:3], LETTERS[1:3]))
tst1[2,2] <- 1
tst1t <- trimImage(tst1)
# check
tst1. <- matrix(1, 1, 1,
dimnames=list(letters[2], LETTERS[2]))
# }
# NOT RUN {
all.equal(tst1t, tst1.)
# }
# NOT RUN {
##
## 2. returnIndices2Keep
##
tst2i <- trimImage(tst1, returnIndices2Keep=TRUE)
tst2a <- trimImage(tst1, returnIndices2Keep=tst2i)
tst2i. <- list(index1=2, index2=2)
# check
# }
# NOT RUN {
all.equal(tst2i, tst2i.)
# }
# NOT RUN {
all.equal(tst2a, tst1.)
# }
# NOT RUN {
##
## 3. trim 0's only
##
tst3 <- array(0, dim=3:5)
tst3[2, 2:3, ] <- 0.5*.Machine$double.eps
tst3[3,,] <- 1
tst3t <- trimImage(tst3, 0)
# check
tst3t. <- tst3[2:3,, ]
# check
# }
# NOT RUN {
all.equal(tst3t, tst3t.)
# }
# NOT RUN {
##
## 4. trim NAs
##
tst4 <- tst1
tst4[1,1] <- NA
tst4[3,] <- NA
tst4t <- trimImage(tst4)
# tst4o == tst4
tst4o <- trimImage(tst4, na.rm=FALSE)
# check
# }
# NOT RUN {
all.equal(tst4t, tst1[2, 2, drop=FALSE])
# }
# NOT RUN {
# }
# NOT RUN {
all.equal(tst4o, tst4)
# }
# NOT RUN {
##
## 5. trim all
##
tst4a <- trimImage(tst1, 1)
tst4a. <- matrix(0,0,0,
dimnames=list(NULL, NULL))
# }
# NOT RUN {
all.equal(tst4a, tst4a.)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab