...
 
Commits (3)
......@@ -69,8 +69,6 @@ See sections ‘The INDEX file’ and ‘Package subdirectories’ in the
* checking examples ... OK
* checking for unstated dependencies in ‘tests’ ... OK
* checking tests ... OK
Running ‘auc.R’
Running ‘constructors.R’
Running ‘runit.R’
Running ‘testthat.R’
* checking for unstated dependencies in vignettes ... OK
......
......@@ -7,6 +7,6 @@ Loading HandTill2001
/home/qwer/git/cyclops/fvafrcu/HandTill2001/R/HandTill2001-package.R: line 29 counts 87 characters.>
Warning messages:
1: In getPackageName(where) :
Created a package name, ‘2019-12-18 17:04:07’, when none found
Created a package name, ‘2019-12-19 11:17:48’, when none found
2: In getPackageName(where) :
Created a package name, ‘2019-12-18 17:04:07’, when none found
Created a package name, ‘2019-12-19 11:17:48’, when none found
checking for file ‘/tmp/RtmpDlflnc/remotes7952ee86b5b/HandTill2001/DESCRIPTION’ ... ✔ checking for file ‘/tmp/RtmpDlflnc/remotes7952ee86b5b/HandTill2001/DESCRIPTION’
checking for file ‘/tmp/RtmpKQDl8N/remotes5a281603893b/HandTill2001/DESCRIPTION’ ... ✔ checking for file ‘/tmp/RtmpKQDl8N/remotes5a281603893b/HandTill2001/DESCRIPTION’
─ preparing ‘HandTill2001’:
✔ checking DESCRIPTION meta-information
✔ checking vignette meta-information
......@@ -42,5 +42,4 @@
** testing if installed package keeps a record of temporary installation path
* DONE (HandTill2001)
Adding ‘HandTill2001_0.2-12.9000_R_x86_64-pc-linux-gnu.tar.gz’ to the cache
[1] TRUE
......
......@@ -7,7 +7,7 @@
─ building ‘HandTill2001_0.2-12.9000.tar.gz’
Running /home/qwer/svn/R/r-devel/build/bin/R CMD INSTALL \
/tmp/RtmpADlXqZ/HandTill2001_0.2-12.9000.tar.gz --install-tests
/tmp/Rtmp3EpDZa/HandTill2001_0.2-12.9000.tar.gz --install-tests
* installing to library ‘/home/qwer/svn/R/r-devel/build/library’
* installing *source* package ‘HandTill2001’ ...
** using staged installation
......@@ -27,14 +27,14 @@
* DONE (HandTill2001)
checking for file ‘/home/qwer/git/cyclops/fvafrcu/HandTill2001/DESCRIPTION’ ... ✔ checking for file ‘/home/qwer/git/cyclops/fvafrcu/HandTill2001/DESCRIPTION’
─ preparing ‘HandTill2001’:
checking DESCRIPTION meta-information ... ✔ checking DESCRIPTION meta-information
checking DESCRIPTION meta-information ... ✔ checking DESCRIPTION meta-information
─ checking for LF line-endings in source and make files
─ checking for empty or unneeded directories
─ looking to see if a ‘data/datalist’ file should be added
─ building ‘HandTill2001_0.2-12.9000.tar.gz’
Running /usr/lib/R/bin/R CMD INSTALL \
/tmp/RtmpMR9QEy/HandTill2001_0.2-12.9000.tar.gz --install-tests
/tmp/Rtmpi8HkbV/HandTill2001_0.2-12.9000.tar.gz --install-tests
* installing to library ‘/home/qwer/R/x86_64-pc-linux-gnu-library/3.3’
* installing *source* package ‘HandTill2001’ ...
** R
......
This diff is collapsed.
......@@ -21,15 +21,6 @@ Type 'q()' to quit R.
Writing NAMESPACE
Loading HandTill2001
Writing NAMESPACE
Writing bincap-class.Rd
Writing multcap-class.Rd
Writing bincap.Rd
Writing multcap.Rd
Writing HandTill2001-package.Rd
Writing auc-methods.Rd
Writing ht01.multipleclass.Rd
Writing ht01.twoclass.Rd
Writing throw.Rd
Warning message:
roxygen2 requires Encoding: UTF-8
>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/transitional.dtd">
<html><head><title>RUNIT TEST PROTOCOL--Wed Dec 18 17:05:47 2019</title>
<html><head><title>RUNIT TEST PROTOCOL--Thu Dec 19 11:18:56 2019</title>
</head>
<body><h1 TRUE>RUNIT TEST PROTOCOL--Wed Dec 18 17:05:47 2019</h1>
<body><h1 TRUE>RUNIT TEST PROTOCOL--Thu Dec 19 11:18:56 2019</h1>
<p>Number of test functions: 1</p>
<p>Number of errors: 0</p>
<p>Number of failures: 0</p>
......
RUNIT TEST PROTOCOL -- Wed Dec 18 17:05:47 2019
RUNIT TEST PROTOCOL -- Thu Dec 19 11:18:56 2019
***********************************************
Number of test functions: 1
Number of errors: 0
......
Loading HandTill2001
Testing HandTill2001
✔ | OK F W S | Context
⠏ | 0 | Testing HandTill2001:::throw() ✔ | 1 1 | Testing HandTill2001:::throw()
────────────────────────────────────────────────────────────────────────────────
test-throw.R:5: warning: throw the HandTill2001 exception
`HandTill2001:::throw(string)` generated an S3 error and you are testing the error message.
* The error has class = c("error", "HandTill2001", "condition")
* Testing with `class` is more robust than testing with `regexp`.
* Do you want `expect_error(..., class = "error")`?
────────────────────────────────────────────────────────────────────────────────
⠏ | 0 | Testing HandTill2001::auc() ⠙ | 2 | Testing HandTill2001::auc() ✔ | 2 | Testing HandTill2001::auc() [0.1 s]
⠏ | 0 | Testing binary classes ✔ | 4 | Testing binary classes
⠏ | 0 | Testing binary classes ✔ | 4 | Testing binary classes
⠏ | 0 | Test for input checks ✔ | 5 | Test for input checks
⠏ | 0 | Testing HandTill2001:::throw() ✔ | 1 | Testing HandTill2001:::throw()
══ Results ═════════════════════════════════════════════════════════════════════
OK: 1
Duration: 0.3 s
OK: 16
Failed: 0
Warnings: 1
Warnings: 0
Skipped: 0
......
../demo/auc.R
\ No newline at end of file
## from system.file("test-tools-1.R", package = "Matrix"):
assertError <- function(expr) {
d.expr <- deparse(substitute(expr))
t.res <- tryCatch(expr, error = function(e) e)
print(t.res)
if (!inherits(t.res, "error")) {
stop(d.expr, "\n\t did not give an error", call. = FALSE)
}
invisible(t.res)
}
assertWarning <- function(expr) {
d.expr <- deparse(substitute(expr))
t.res <- tryCatch(expr, warning = function(w) w)
if (!inherits(t.res, "warning")) {
stop(d.expr, "\n\t did not give a warning", call. = FALSE)
}
invisible(t.res)
}
library("HandTill2001")
data(ht01.twoclass)
new("bincap",
response = as.factor(ht01.twoclass$observed),
predicted = ht01.twoclass$predicted
)
assertError(
new("bincap",
response = ht01.twoclass$observed,
predicted = ht01.twoclass$predicted
)
)
assertError(
new("bincap",
response = as.factor(ht01.twoclass$observed),
predicted = as.data.frame(ht01.twoclass$predicted)
)
)
assertError(
new("bincap",
true = 1
)
)
data(ht01.multipleclass)
new("multcap",
response = ht01.multipleclass$observed,
predicted = as.matrix(ht01.multipleclass[, levels(ht01.multipleclass$observed)])
)
assertError(
new("multcap",
response = as.numeric(ht01.multipleclass$observed),
predicted = as.matrix(ht01.multipleclass[, levels(ht01.multipleclass$observed)])
)
)
assertError(
new("multcap",
response = ht01.multipleclass$observed,
predicted = ht01.multipleclass[, levels(ht01.multipleclass$observed)]
)
)
assertError(
new("multcap",
true = 1
)
)
###########################################################
po <- ht01.multipleclass[, levels(ht01.multipleclass$observed)]
ro <- ht01.multipleclass$observed
######## get a subset
i <- c(1, 73, 157, 170, 182, 186)
p <- po[i, ]
r <- ro[i]
multcap(
response = r,
predicted = as.matrix(p)
)
## r extraneous levels
r <- ro[i]
p <- po[i, ]
levels(r) <- c(levels(r), "foo", "bar")
assertWarning(
multcap(
response = r,
predicted = as.matrix(p)
)
)
## r levels unmatched by p
r <- ro[i]
p <- po[i, ]
levels(r) <- c(levels(r), "foo", "bar")
assertWarning(
multcap(
response = r,
predicted = as.matrix(p)
)
)
## r values unmatched by p
r <- ro[i]
p <- po[i, 1:5]
assertError(
multcap(
response = r,
predicted = as.matrix(p)
)
)
## p columns unmatched by levels(r)
r <- ro[i]
p <- po[i, ]
p$foo <- NA
assertError(
multcap(
response = r,
predicted = as.matrix(p)
)
)
testthat::context("Testing HandTill2001::auc()")
testthat::test_that("binary", {
data(ht01.twoclass, package = "HandTill2001")
object <- HandTill2001::bincap(response = as.factor(ht01.twoclass$observed),
predicted = ht01.twoclass$predicted,
true = "1")
result <- HandTill2001::auc(object)
expectation <- 0.802607561929596
testthat:::expect_equal(result, expectation)
})
testthat::test_that("multiple", {
data(ht01.multipleclass, package = "HandTill2001")
object <- HandTill2001::multcap(response = ht01.multipleclass$observed,
predicted = as.matrix(ht01.multipleclass[,
levels(ht01.multipleclass$observed)]))
result <- HandTill2001::auc(object)
expectation <- 0.947211779448622
testthat:::expect_equal(result, expectation)
})
This diff is collapsed.
......@@ -4,6 +4,7 @@ testthat::test_that("throw the HandTill2001 exception", {
string <- "hello, testthat"
testthat::expect_error(
HandTill2001:::throw(string),
error_message
regexp = error_message,
class = c("error", "HandTill2001", "condition")
)
})