Last updated on 2020-02-19 10:48:48 CET.
Flavor | Version | Tinstall | Tcheck | Ttotal | Status | Flags |
---|---|---|---|---|---|---|
r-devel-linux-x86_64-debian-clang | 0.1.1 | 11.56 | 117.51 | 129.07 | ERROR | |
r-devel-linux-x86_64-debian-gcc | 0.1.1 | 10.28 | 91.76 | 102.04 | ERROR | |
r-devel-linux-x86_64-fedora-clang | 0.1.1 | 157.80 | ERROR | |||
r-devel-linux-x86_64-fedora-gcc | 0.1.1 | 156.46 | ERROR | |||
r-devel-windows-ix86+x86_64 | 0.1.1 | 33.00 | 129.00 | 162.00 | OK | |
r-devel-windows-ix86+x86_64-gcc8 | 0.1.1 | 48.00 | 179.00 | 227.00 | OK | |
r-patched-linux-x86_64 | 0.1.1 | 9.66 | 105.78 | 115.44 | OK | |
r-patched-solaris-x86 | 0.1.1 | 219.20 | ERROR | |||
r-release-linux-x86_64 | 0.1.1 | 12.41 | 104.95 | 117.36 | OK | |
r-release-windows-ix86+x86_64 | 0.1.1 | 23.00 | 122.00 | 145.00 | OK | |
r-release-osx-x86_64 | 0.1.1 | OK | ||||
r-oldrel-windows-ix86+x86_64 | 0.1.1 | 16.00 | 119.00 | 135.00 | OK | |
r-oldrel-osx-x86_64 | 0.1.1 | OK |
Version: 0.1.1
Check: tests
Result: ERROR
Running 'testthat.R' [18s/19s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
> library(testthat)
> library(classiFunc)
>
> test_check("classiFunc")
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKernel(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
ker = "Ker.norm", h = 50)
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKernel.R#34: classiKernel(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
ker = "Ker.norm", h = 50)
where 2: eval(code, test_env)
where 3: eval(code, test_env)
where 4: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 8: doTryCatch(return(expr), name, parentenv, handler)
where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 10: tryCatchList(expr, classes, parentenv, handlers)
where 11: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 12: test_code(desc, code, env = parent.frame())
where 13 at testthat/test_classiKernel.R#31: test_that("classiKernel works for different Kernels", {
data(phoneme, package = "fda.usc")
mod1 = classiKernel(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
ker = "Ker.norm", h = 50)
mod2 = classiKernel(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
h = 0.1, ker = "Ker.epa")
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE, nrows = nrow(mod1$fdata),
ncols = length(unique(mod1$classes)))
pred1.2 = predict(mod2, newdata = phoneme[["test"]]$dat,
predict.type = "prob")
pred2 = predict(mod2, newdata = phoneme[["test"]]$dat, predict.type = "response")
checkmate::expect_factor(pred2, any.missing = FALSE, levels = levels(phoneme[["classtest"]]))
})
where 14: eval(code, test_env)
where 15: eval(code, test_env)
where 16: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 17: doTryCatch(return(expr), name, parentenv, handler)
where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 20: doTryCatch(return(expr), name, parentenv, handler)
where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 22: tryCatchList(expr, classes, parentenv, handlers)
where 23: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 24: test_code(NULL, exprs, env)
where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 26: force(code)
where 27: doWithOneRestart(return(expr), restart)
where 28: withOneRestart(expr, restarts[[1L]])
where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 31: FUN(X[[i]], ...)
where 32: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 33: force(code)
where 34: doWithOneRestart(return(expr), restart)
where 35: withOneRestart(expr, restarts[[1L]])
where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 37: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 40: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 41: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), h = 1, metric = "L2",
ker = "Ker.norm", nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, custom.ker = function(u) {
return(dnorm(u))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertNumeric(h, lower = 0, len = 1L)
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
assertChoice(ker, choices = kerChoices())
assertChoice(metric, choices = metricChoices())
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !checkmate::anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
if (ker != "custom.ker")
custom.ker = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, h = h, metric = metric, ker = ker, custom.metric = custom.metric,
custom.ker = custom.ker, nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKernel"
return(ret)
}
<bytecode: 0xb2ee320>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKernel in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
-- 1. Error: classiKernel works for different Kernels (@test_classiKernel.R#34)
the condition has length > 1
Backtrace:
1. classiFunc::classiKernel(...)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKernel(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKernel.R#65: classiKernel(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
where 3: withCallingHandlers(code, warning = function(condition) {
out$push(condition)
maybe_restart("muffleWarning")
})
where 4: .capture(act$val <- eval_bare(quo_get_expr(.quo), quo_get_env(.quo)),
...)
where 5: quasi_capture(enquo(object), label, capture_warnings)
where 6 at testthat/test_classiKernel.R#65: expect_warning({
mod1 = classiKernel(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
})
where 7: eval(code, test_env)
where 8: eval(code, test_env)
where 9: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 10: doTryCatch(return(expr), name, parentenv, handler)
where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 13: doTryCatch(return(expr), name, parentenv, handler)
where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 15: tryCatchList(expr, classes, parentenv, handlers)
where 16: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 17: test_code(desc, code, env = parent.frame())
where 18 at testthat/test_classiKernel.R#53: test_that("classiKernel works for DTI data set (contains missing values)",
{
data("DTI_original")
DTI = DTI_original
classes = DTI[, "case"]
set.seed(123)
train_inds = sample(1:nrow(DTI), size = 0.8 * nrow(DTI),
replace = FALSE)
test_inds = (1:nrow(DTI))[!(1:nrow(DTI)) %in% train_inds]
DTI = DTI[, !colnames(DTI) == "target"]
expect_warning({
mod1 = classiKernel(classes = classes[train_inds],
fdata = DTI[train_inds, "cca"])
})
expect_warning({
mod2 = classiKernel(classes = classes[train_inds],
fdata = DTI[train_inds, "cca"], h = 10000)
})
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(levels(mod1$classes)))
pred2 = predict(mod2, newdata = DTI[train_inds, "cca"],
predict.type = "prob")
checkmate::expect_matrix(pred2, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(levels(mod1$classes)))
pred3 = predict(mod2, newdata = DTI[train_inds, "cca"],
predict.type = "response")
checkmate::assert_true(all(pred3 == 1))
checkmate::expect_factor(pred3, any.missing = FALSE,
levels = levels(mod2$classes))
})
where 19: eval(code, test_env)
where 20: eval(code, test_env)
where 21: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 22: doTryCatch(return(expr), name, parentenv, handler)
where 23: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 24: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 25: doTryCatch(return(expr), name, parentenv, handler)
where 26: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 27: tryCatchList(expr, classes, parentenv, handlers)
where 28: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 29: test_code(NULL, exprs, env)
where 30: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 31: force(code)
where 32: doWithOneRestart(return(expr), restart)
where 33: withOneRestart(expr, restarts[[1L]])
where 34: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 35: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 36: FUN(X[[i]], ...)
where 37: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 38: force(code)
where 39: doWithOneRestart(return(expr), restart)
where 40: withOneRestart(expr, restarts[[1L]])
where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 42: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 43: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 44: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 45: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 46: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), h = 1, metric = "L2",
ker = "Ker.norm", nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, custom.ker = function(u) {
return(dnorm(u))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertNumeric(h, lower = 0, len = 1L)
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
assertChoice(ker, choices = kerChoices())
assertChoice(metric, choices = metricChoices())
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !checkmate::anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
if (ker != "custom.ker")
custom.ker = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, h = h, metric = metric, ker = ker, custom.metric = custom.metric,
custom.ker = custom.ker, nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKernel"
return(ret)
}
<bytecode: 0xb2ee320>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKernel in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
-- 2. Error: classiKernel works for DTI data set (contains missing values) (@tes
the condition has length > 1
Backtrace:
1. testthat::expect_warning(...)
6. classiFunc::classiKernel(...)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data)
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKnn.R#35: classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data)
where 2: eval(code, test_env)
where 3: eval(code, test_env)
where 4: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 8: doTryCatch(return(expr), name, parentenv, handler)
where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 10: tryCatchList(expr, classes, parentenv, handlers)
where 11: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 12: test_code(desc, code, env = parent.frame())
where 13 at testthat/test_classiKnn.R#32: test_that("classiKnn works for phoneme data set from fda.usc package",
{
data(phoneme, package = "fda.usc")
mod1 = classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data)
mod2 = classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
nderiv = 1L, knn = 3L)
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(unique(mod1$classes)))
pred2 = predict(mod2, newdata = phoneme[["test"]]$dat,
predict.type = "response")
checkmate::expect_factor(pred2, any.missing = FALSE,
levels = levels(phoneme[["classtest"]]))
})
where 14: eval(code, test_env)
where 15: eval(code, test_env)
where 16: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 17: doTryCatch(return(expr), name, parentenv, handler)
where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 20: doTryCatch(return(expr), name, parentenv, handler)
where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 22: tryCatchList(expr, classes, parentenv, handlers)
where 23: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 24: test_code(NULL, exprs, env)
where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 26: force(code)
where 27: doWithOneRestart(return(expr), restart)
where 28: withOneRestart(expr, restarts[[1L]])
where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 31: FUN(X[[i]], ...)
where 32: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 33: force(code)
where 34: doWithOneRestart(return(expr), restart)
where 35: withOneRestart(expr, restarts[[1L]])
where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 37: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 40: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 41: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), knn = 1L, metric = "L2",
nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertIntegerish(knn, lower = 1L, upper = nrow(fdata), len = 1)
assertChoice(metric, choices = metricChoices())
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, knn = knn, metric = metric, custom.metric = custom.metric,
nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKnn"
return(ret)
}
<bytecode: 0xb3b17f8>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKnn in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
-- 3. Error: classiKnn works for phoneme data set from fda.usc package (@test_cl
the condition has length > 1
Backtrace:
1. classiFunc::classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKnn.R#103: classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
where 3: withCallingHandlers(code, warning = function(condition) {
out$push(condition)
maybe_restart("muffleWarning")
})
where 4: .capture(act$val <- eval_bare(quo_get_expr(.quo), quo_get_env(.quo)),
...)
where 5: quasi_capture(enquo(object), label, capture_warnings)
where 6 at testthat/test_classiKnn.R#103: expect_warning({
mod1 = classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
})
where 7: eval(code, test_env)
where 8: eval(code, test_env)
where 9: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 10: doTryCatch(return(expr), name, parentenv, handler)
where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 13: doTryCatch(return(expr), name, parentenv, handler)
where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 15: tryCatchList(expr, classes, parentenv, handlers)
where 16: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 17: test_code(desc, code, env = parent.frame())
where 18 at testthat/test_classiKnn.R#91: test_that("classiKnn works for DTI data set (contains missing values)",
{
data("DTI_original")
DTI = DTI_original
classes = DTI[, "case"]
set.seed(123)
train_inds = sample(1:nrow(DTI), size = 0.8 * nrow(DTI),
replace = FALSE)
test_inds = (1:nrow(DTI))[!(1:nrow(DTI)) %in% train_inds]
DTI = DTI[, !colnames(DTI) == "target"]
expect_warning({
mod1 = classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
})
expect_warning({
mod2 = classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"], nderiv = 1L, knn = 3L)
})
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(levels(mod1$classes)))
pred2 = predict(mod2, newdata = DTI[train_inds, "cca"],
predict.type = "response")
checkmate::expect_factor(pred2, any.missing = FALSE,
levels = levels(mod2$classes))
pred3 = predict(mod2, newdata = DTI[1, "cca"], predict.type = "response")
checkmate::expect_factor(pred3, any.missing = FALSE,
levels = levels(mod2$classes))
})
where 19: eval(code, test_env)
where 20: eval(code, test_env)
where 21: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 22: doTryCatch(return(expr), name, parentenv, handler)
where 23: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 24: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 25: doTryCatch(return(expr), name, parentenv, handler)
where 26: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 27: tryCatchList(expr, classes, parentenv, handlers)
where 28: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 29: test_code(NULL, exprs, env)
where 30: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 31: force(code)
where 32: doWithOneRestart(return(expr), restart)
where 33: withOneRestart(expr, restarts[[1L]])
where 34: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 35: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 36: FUN(X[[i]], ...)
where 37: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 38: force(code)
where 39: doWithOneRestart(return(expr), restart)
where 40: withOneRestart(expr, restarts[[1L]])
where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 42: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 43: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 44: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 45: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 46: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), knn = 1L, metric = "L2",
nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertIntegerish(knn, lower = 1L, upper = nrow(fdata), len = 1)
assertChoice(metric, choices = metricChoices())
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, knn = knn, metric = metric, custom.metric = custom.metric,
nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKnn"
return(ret)
}
<bytecode: 0xb3b17f8>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKnn in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
-- 4. Error: classiKnn works for DTI data set (contains missing values) (@test_c
the condition has length > 1
Backtrace:
1. testthat::expect_warning(...)
6. classiFunc::classiKnn(...)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKnn(classes = classes[train_inds], grid = Growth$age_grid,
fdata = Growth$height[train_inds, ])
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKnn.R#132: classiKnn(classes = classes[train_inds], grid = Growth$age_grid,
fdata = Growth$height[train_inds, ])
where 2: eval(code, test_env)
where 3: eval(code, test_env)
where 4: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 8: doTryCatch(return(expr), name, parentenv, handler)
where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 10: tryCatchList(expr, classes, parentenv, handlers)
where 11: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 12: test_code(desc, code, env = parent.frame())
where 13 at testthat/test_classiKnn.R#122: test_that("classiKnn works for growth data set (contains irregular grid)",
{
data(Growth_irregular, package = "classiFunc")
Growth = Growth_irregular
classes = Growth$sex
set.seed(123)
train_inds = sample(1:length(classes), size = 0.8 * length(classes),
replace = FALSE)
test_inds = (1:length(classes))[!(1:length(classes)) %in%
train_inds]
mod1 = classiKnn(classes = classes[train_inds], grid = Growth$age_grid,
fdata = Growth$height[train_inds, ])
mod2 = classiKnn(classes = classes[train_inds], grid = Growth$age_grid,
fdata = Growth$height[train_inds, ], nderiv = 1L,
knn = 3L)
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(levels(mod1$classes)))
pred2 = predict(mod2, newdata = Growth$height[test_inds,
], predict.type = "response")
checkmate::expect_factor(pred2, any.missing = FALSE,
levels = levels(mod2$classes))
pred3 = predict(mod2, newdata = Growth$height[test_inds,
], predict.type = "response")
checkmate::expect_factor(pred3, any.missing = FALSE,
levels = levels(mod2$classes))
})
where 14: eval(code, test_env)
where 15: eval(code, test_env)
where 16: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 17: doTryCatch(return(expr), name, parentenv, handler)
where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 20: doTryCatch(return(expr), name, parentenv, handler)
where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 22: tryCatchList(expr, classes, parentenv, handlers)
where 23: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 24: test_code(NULL, exprs, env)
where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 26: force(code)
where 27: doWithOneRestart(return(expr), restart)
where 28: withOneRestart(expr, restarts[[1L]])
where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 31: FUN(X[[i]], ...)
where 32: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 33: force(code)
where 34: doWithOneRestart(return(expr), restart)
where 35: withOneRestart(expr, restarts[[1L]])
where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 37: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 40: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 41: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), knn = 1L, metric = "L2",
nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertIntegerish(knn, lower = 1L, upper = nrow(fdata), len = 1)
assertChoice(metric, choices = metricChoices())
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, knn = knn, metric = metric, custom.metric = custom.metric,
nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKnn"
return(ret)
}
<bytecode: 0xb3b17f8>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKnn in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
-- 5. Error: classiKnn works for growth data set (contains irregular grid) (@tes
the condition has length > 1
Backtrace:
1. classiFunc::classiKnn(...)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L)
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_parallelComputeDistMat.R#22: classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L)
where 2: eval(code, test_env)
where 3: eval(code, test_env)
where 4: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 8: doTryCatch(return(expr), name, parentenv, handler)
where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 10: tryCatchList(expr, classes, parentenv, handlers)
where 11: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 12: test_code(desc, code, env = parent.frame())
where 13 at testthat/test_parallelComputeDistMat.R#17: test_that("Works with kernel / knn", {
set.seed(123)
trn = matrix(rnorm(n = 20), 5, byrow = TRUE)
tst = matrix(rnorm(n = 40), 10, byrow = TRUE)
mod = classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L)
pred = predict(mod, newdata = tst)
pred2 = predict(mod, newdata = tst, parallel = TRUE, batches = 2)
expect_true(all.equal(pred, pred2))
mod = classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L,
metric = "shortEuclidean", dmin = 0, dmax = 1/2)
pred = predict(mod, newdata = tst)
pred2 = predict(mod, newdata = tst, parallel = TRUE, batches = 2)
expect_true(all.equal(pred, pred2))
if (require("dtw")) {
mod = classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 2L,
metric = "dtw")
pred = predict(mod, newdata = tst)
expect_message({
pred2 = predict(mod, newdata = tst, parallel = TRUE,
batches = 3)
}, "Loading")
expect_true(all.equal(pred, pred2))
}
})
where 14: eval(code, test_env)
where 15: eval(code, test_env)
where 16: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 17: doTryCatch(return(expr), name, parentenv, handler)
where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 20: doTryCatch(return(expr), name, parentenv, handler)
where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 22: tryCatchList(expr, classes, parentenv, handlers)
where 23: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 24: test_code(NULL, exprs, env)
where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 26: force(code)
where 27: doWithOneRestart(return(expr), restart)
where 28: withOneRestart(expr, restarts[[1L]])
where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 31: FUN(X[[i]], ...)
where 32: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 33: force(code)
where 34: doWithOneRestart(return(expr), restart)
where 35: withOneRestart(expr, restarts[[1L]])
where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 37: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 40: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 41: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), knn = 1L, metric = "L2",
nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertIntegerish(knn, lower = 1L, upper = nrow(fdata), len = 1)
assertChoice(metric, choices = metricChoices())
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, knn = knn, metric = metric, custom.metric = custom.metric,
nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKnn"
return(ret)
}
<bytecode: 0xb3b17f8>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKnn in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
-- 6. Error: Works with kernel / knn (@test_parallelComputeDistMat.R#22) ------
the condition has length > 1
Backtrace:
1. classiFunc::classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L)
== testthat results ===========================================================
[ OK: 34 | SKIPPED: 0 | WARNINGS: 784 | FAILED: 6 ]
1. Error: classiKernel works for different Kernels (@test_classiKernel.R#34)
2. Error: classiKernel works for DTI data set (contains missing values) (@test_classiKernel.R#65)
3. Error: classiKnn works for phoneme data set from fda.usc package (@test_classiKnn.R#35)
4. Error: classiKnn works for DTI data set (contains missing values) (@test_classiKnn.R#103)
5. Error: classiKnn works for growth data set (contains irregular grid) (@test_classiKnn.R#132)
6. Error: Works with kernel / knn (@test_parallelComputeDistMat.R#22)
Error: testthat unit tests failed
Execution halted
Flavor: r-devel-linux-x86_64-debian-clang
Version: 0.1.1
Check: tests
Result: ERROR
Running ‘testthat.R’ [14s/19s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
> library(testthat)
> library(classiFunc)
>
> test_check("classiFunc")
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKernel(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
ker = "Ker.norm", h = 50)
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKernel.R#34: classiKernel(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
ker = "Ker.norm", h = 50)
where 2: eval(code, test_env)
where 3: eval(code, test_env)
where 4: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 8: doTryCatch(return(expr), name, parentenv, handler)
where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 10: tryCatchList(expr, classes, parentenv, handlers)
where 11: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 12: test_code(desc, code, env = parent.frame())
where 13 at testthat/test_classiKernel.R#31: test_that("classiKernel works for different Kernels", {
data(phoneme, package = "fda.usc")
mod1 = classiKernel(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
ker = "Ker.norm", h = 50)
mod2 = classiKernel(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
h = 0.1, ker = "Ker.epa")
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE, nrows = nrow(mod1$fdata),
ncols = length(unique(mod1$classes)))
pred1.2 = predict(mod2, newdata = phoneme[["test"]]$dat,
predict.type = "prob")
pred2 = predict(mod2, newdata = phoneme[["test"]]$dat, predict.type = "response")
checkmate::expect_factor(pred2, any.missing = FALSE, levels = levels(phoneme[["classtest"]]))
})
where 14: eval(code, test_env)
where 15: eval(code, test_env)
where 16: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 17: doTryCatch(return(expr), name, parentenv, handler)
where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 20: doTryCatch(return(expr), name, parentenv, handler)
where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 22: tryCatchList(expr, classes, parentenv, handlers)
where 23: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 24: test_code(NULL, exprs, env)
where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 26: force(code)
where 27: doWithOneRestart(return(expr), restart)
where 28: withOneRestart(expr, restarts[[1L]])
where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 31: FUN(X[[i]], ...)
where 32: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 33: force(code)
where 34: doWithOneRestart(return(expr), restart)
where 35: withOneRestart(expr, restarts[[1L]])
where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 37: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 40: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 41: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), h = 1, metric = "L2",
ker = "Ker.norm", nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, custom.ker = function(u) {
return(dnorm(u))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertNumeric(h, lower = 0, len = 1L)
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
assertChoice(ker, choices = kerChoices())
assertChoice(metric, choices = metricChoices())
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !checkmate::anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
if (ker != "custom.ker")
custom.ker = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, h = h, metric = metric, ker = ker, custom.metric = custom.metric,
custom.ker = custom.ker, nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKernel"
return(ret)
}
<bytecode: 0x55d51e82caa8>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKernel in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 1. Error: classiKernel works for different Kernels (@test_classiKernel.R#34)
the condition has length > 1
Backtrace:
1. classiFunc::classiKernel(...)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKernel(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKernel.R#65: classiKernel(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
where 3: withCallingHandlers(code, warning = function(condition) {
out$push(condition)
maybe_restart("muffleWarning")
})
where 4: .capture(act$val <- eval_bare(quo_get_expr(.quo), quo_get_env(.quo)),
...)
where 5: quasi_capture(enquo(object), label, capture_warnings)
where 6 at testthat/test_classiKernel.R#65: expect_warning({
mod1 = classiKernel(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
})
where 7: eval(code, test_env)
where 8: eval(code, test_env)
where 9: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 10: doTryCatch(return(expr), name, parentenv, handler)
where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 13: doTryCatch(return(expr), name, parentenv, handler)
where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 15: tryCatchList(expr, classes, parentenv, handlers)
where 16: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 17: test_code(desc, code, env = parent.frame())
where 18 at testthat/test_classiKernel.R#53: test_that("classiKernel works for DTI data set (contains missing values)",
{
data("DTI_original")
DTI = DTI_original
classes = DTI[, "case"]
set.seed(123)
train_inds = sample(1:nrow(DTI), size = 0.8 * nrow(DTI),
replace = FALSE)
test_inds = (1:nrow(DTI))[!(1:nrow(DTI)) %in% train_inds]
DTI = DTI[, !colnames(DTI) == "target"]
expect_warning({
mod1 = classiKernel(classes = classes[train_inds],
fdata = DTI[train_inds, "cca"])
})
expect_warning({
mod2 = classiKernel(classes = classes[train_inds],
fdata = DTI[train_inds, "cca"], h = 10000)
})
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(levels(mod1$classes)))
pred2 = predict(mod2, newdata = DTI[train_inds, "cca"],
predict.type = "prob")
checkmate::expect_matrix(pred2, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(levels(mod1$classes)))
pred3 = predict(mod2, newdata = DTI[train_inds, "cca"],
predict.type = "response")
checkmate::assert_true(all(pred3 == 1))
checkmate::expect_factor(pred3, any.missing = FALSE,
levels = levels(mod2$classes))
})
where 19: eval(code, test_env)
where 20: eval(code, test_env)
where 21: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 22: doTryCatch(return(expr), name, parentenv, handler)
where 23: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 24: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 25: doTryCatch(return(expr), name, parentenv, handler)
where 26: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 27: tryCatchList(expr, classes, parentenv, handlers)
where 28: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 29: test_code(NULL, exprs, env)
where 30: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 31: force(code)
where 32: doWithOneRestart(return(expr), restart)
where 33: withOneRestart(expr, restarts[[1L]])
where 34: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 35: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 36: FUN(X[[i]], ...)
where 37: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 38: force(code)
where 39: doWithOneRestart(return(expr), restart)
where 40: withOneRestart(expr, restarts[[1L]])
where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 42: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 43: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 44: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 45: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 46: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), h = 1, metric = "L2",
ker = "Ker.norm", nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, custom.ker = function(u) {
return(dnorm(u))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertNumeric(h, lower = 0, len = 1L)
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
assertChoice(ker, choices = kerChoices())
assertChoice(metric, choices = metricChoices())
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !checkmate::anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
if (ker != "custom.ker")
custom.ker = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, h = h, metric = metric, ker = ker, custom.metric = custom.metric,
custom.ker = custom.ker, nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKernel"
return(ret)
}
<bytecode: 0x55d51e82caa8>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKernel in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 2. Error: classiKernel works for DTI data set (contains missing values) (@tes
the condition has length > 1
Backtrace:
1. testthat::expect_warning(...)
6. classiFunc::classiKernel(...)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data)
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKnn.R#35: classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data)
where 2: eval(code, test_env)
where 3: eval(code, test_env)
where 4: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 8: doTryCatch(return(expr), name, parentenv, handler)
where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 10: tryCatchList(expr, classes, parentenv, handlers)
where 11: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 12: test_code(desc, code, env = parent.frame())
where 13 at testthat/test_classiKnn.R#32: test_that("classiKnn works for phoneme data set from fda.usc package",
{
data(phoneme, package = "fda.usc")
mod1 = classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data)
mod2 = classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
nderiv = 1L, knn = 3L)
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(unique(mod1$classes)))
pred2 = predict(mod2, newdata = phoneme[["test"]]$dat,
predict.type = "response")
checkmate::expect_factor(pred2, any.missing = FALSE,
levels = levels(phoneme[["classtest"]]))
})
where 14: eval(code, test_env)
where 15: eval(code, test_env)
where 16: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 17: doTryCatch(return(expr), name, parentenv, handler)
where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 20: doTryCatch(return(expr), name, parentenv, handler)
where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 22: tryCatchList(expr, classes, parentenv, handlers)
where 23: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 24: test_code(NULL, exprs, env)
where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 26: force(code)
where 27: doWithOneRestart(return(expr), restart)
where 28: withOneRestart(expr, restarts[[1L]])
where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 31: FUN(X[[i]], ...)
where 32: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 33: force(code)
where 34: doWithOneRestart(return(expr), restart)
where 35: withOneRestart(expr, restarts[[1L]])
where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 37: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 40: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 41: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), knn = 1L, metric = "L2",
nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertIntegerish(knn, lower = 1L, upper = nrow(fdata), len = 1)
assertChoice(metric, choices = metricChoices())
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, knn = knn, metric = metric, custom.metric = custom.metric,
nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKnn"
return(ret)
}
<bytecode: 0x55d51e8a7b30>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKnn in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 3. Error: classiKnn works for phoneme data set from fda.usc package (@test_cl
the condition has length > 1
Backtrace:
1. classiFunc::classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKnn.R#103: classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
where 3: withCallingHandlers(code, warning = function(condition) {
out$push(condition)
maybe_restart("muffleWarning")
})
where 4: .capture(act$val <- eval_bare(quo_get_expr(.quo), quo_get_env(.quo)),
...)
where 5: quasi_capture(enquo(object), label, capture_warnings)
where 6 at testthat/test_classiKnn.R#103: expect_warning({
mod1 = classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
})
where 7: eval(code, test_env)
where 8: eval(code, test_env)
where 9: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 10: doTryCatch(return(expr), name, parentenv, handler)
where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 13: doTryCatch(return(expr), name, parentenv, handler)
where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 15: tryCatchList(expr, classes, parentenv, handlers)
where 16: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 17: test_code(desc, code, env = parent.frame())
where 18 at testthat/test_classiKnn.R#91: test_that("classiKnn works for DTI data set (contains missing values)",
{
data("DTI_original")
DTI = DTI_original
classes = DTI[, "case"]
set.seed(123)
train_inds = sample(1:nrow(DTI), size = 0.8 * nrow(DTI),
replace = FALSE)
test_inds = (1:nrow(DTI))[!(1:nrow(DTI)) %in% train_inds]
DTI = DTI[, !colnames(DTI) == "target"]
expect_warning({
mod1 = classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
})
expect_warning({
mod2 = classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"], nderiv = 1L, knn = 3L)
})
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(levels(mod1$classes)))
pred2 = predict(mod2, newdata = DTI[train_inds, "cca"],
predict.type = "response")
checkmate::expect_factor(pred2, any.missing = FALSE,
levels = levels(mod2$classes))
pred3 = predict(mod2, newdata = DTI[1, "cca"], predict.type = "response")
checkmate::expect_factor(pred3, any.missing = FALSE,
levels = levels(mod2$classes))
})
where 19: eval(code, test_env)
where 20: eval(code, test_env)
where 21: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 22: doTryCatch(return(expr), name, parentenv, handler)
where 23: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 24: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 25: doTryCatch(return(expr), name, parentenv, handler)
where 26: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 27: tryCatchList(expr, classes, parentenv, handlers)
where 28: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 29: test_code(NULL, exprs, env)
where 30: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 31: force(code)
where 32: doWithOneRestart(return(expr), restart)
where 33: withOneRestart(expr, restarts[[1L]])
where 34: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 35: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 36: FUN(X[[i]], ...)
where 37: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 38: force(code)
where 39: doWithOneRestart(return(expr), restart)
where 40: withOneRestart(expr, restarts[[1L]])
where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 42: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 43: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 44: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 45: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 46: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), knn = 1L, metric = "L2",
nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertIntegerish(knn, lower = 1L, upper = nrow(fdata), len = 1)
assertChoice(metric, choices = metricChoices())
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, knn = knn, metric = metric, custom.metric = custom.metric,
nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKnn"
return(ret)
}
<bytecode: 0x55d51e8a7b30>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKnn in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 4. Error: classiKnn works for DTI data set (contains missing values) (@test_c
the condition has length > 1
Backtrace:
1. testthat::expect_warning(...)
6. classiFunc::classiKnn(...)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKnn(classes = classes[train_inds], grid = Growth$age_grid,
fdata = Growth$height[train_inds, ])
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKnn.R#132: classiKnn(classes = classes[train_inds], grid = Growth$age_grid,
fdata = Growth$height[train_inds, ])
where 2: eval(code, test_env)
where 3: eval(code, test_env)
where 4: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 8: doTryCatch(return(expr), name, parentenv, handler)
where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 10: tryCatchList(expr, classes, parentenv, handlers)
where 11: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 12: test_code(desc, code, env = parent.frame())
where 13 at testthat/test_classiKnn.R#122: test_that("classiKnn works for growth data set (contains irregular grid)",
{
data(Growth_irregular, package = "classiFunc")
Growth = Growth_irregular
classes = Growth$sex
set.seed(123)
train_inds = sample(1:length(classes), size = 0.8 * length(classes),
replace = FALSE)
test_inds = (1:length(classes))[!(1:length(classes)) %in%
train_inds]
mod1 = classiKnn(classes = classes[train_inds], grid = Growth$age_grid,
fdata = Growth$height[train_inds, ])
mod2 = classiKnn(classes = classes[train_inds], grid = Growth$age_grid,
fdata = Growth$height[train_inds, ], nderiv = 1L,
knn = 3L)
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(levels(mod1$classes)))
pred2 = predict(mod2, newdata = Growth$height[test_inds,
], predict.type = "response")
checkmate::expect_factor(pred2, any.missing = FALSE,
levels = levels(mod2$classes))
pred3 = predict(mod2, newdata = Growth$height[test_inds,
], predict.type = "response")
checkmate::expect_factor(pred3, any.missing = FALSE,
levels = levels(mod2$classes))
})
where 14: eval(code, test_env)
where 15: eval(code, test_env)
where 16: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 17: doTryCatch(return(expr), name, parentenv, handler)
where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 20: doTryCatch(return(expr), name, parentenv, handler)
where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 22: tryCatchList(expr, classes, parentenv, handlers)
where 23: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 24: test_code(NULL, exprs, env)
where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 26: force(code)
where 27: doWithOneRestart(return(expr), restart)
where 28: withOneRestart(expr, restarts[[1L]])
where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 31: FUN(X[[i]], ...)
where 32: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 33: force(code)
where 34: doWithOneRestart(return(expr), restart)
where 35: withOneRestart(expr, restarts[[1L]])
where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 37: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 40: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 41: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), knn = 1L, metric = "L2",
nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertIntegerish(knn, lower = 1L, upper = nrow(fdata), len = 1)
assertChoice(metric, choices = metricChoices())
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, knn = knn, metric = metric, custom.metric = custom.metric,
nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKnn"
return(ret)
}
<bytecode: 0x55d51e8a7b30>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKnn in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 5. Error: classiKnn works for growth data set (contains irregular grid) (@tes
the condition has length > 1
Backtrace:
1. classiFunc::classiKnn(...)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L)
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_parallelComputeDistMat.R#22: classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L)
where 2: eval(code, test_env)
where 3: eval(code, test_env)
where 4: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 8: doTryCatch(return(expr), name, parentenv, handler)
where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 10: tryCatchList(expr, classes, parentenv, handlers)
where 11: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 12: test_code(desc, code, env = parent.frame())
where 13 at testthat/test_parallelComputeDistMat.R#17: test_that("Works with kernel / knn", {
set.seed(123)
trn = matrix(rnorm(n = 20), 5, byrow = TRUE)
tst = matrix(rnorm(n = 40), 10, byrow = TRUE)
mod = classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L)
pred = predict(mod, newdata = tst)
pred2 = predict(mod, newdata = tst, parallel = TRUE, batches = 2)
expect_true(all.equal(pred, pred2))
mod = classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L,
metric = "shortEuclidean", dmin = 0, dmax = 1/2)
pred = predict(mod, newdata = tst)
pred2 = predict(mod, newdata = tst, parallel = TRUE, batches = 2)
expect_true(all.equal(pred, pred2))
if (require("dtw")) {
mod = classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 2L,
metric = "dtw")
pred = predict(mod, newdata = tst)
expect_message({
pred2 = predict(mod, newdata = tst, parallel = TRUE,
batches = 3)
}, "Loading")
expect_true(all.equal(pred, pred2))
}
})
where 14: eval(code, test_env)
where 15: eval(code, test_env)
where 16: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 17: doTryCatch(return(expr), name, parentenv, handler)
where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 20: doTryCatch(return(expr), name, parentenv, handler)
where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 22: tryCatchList(expr, classes, parentenv, handlers)
where 23: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 24: test_code(NULL, exprs, env)
where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 26: force(code)
where 27: doWithOneRestart(return(expr), restart)
where 28: withOneRestart(expr, restarts[[1L]])
where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 31: FUN(X[[i]], ...)
where 32: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 33: force(code)
where 34: doWithOneRestart(return(expr), restart)
where 35: withOneRestart(expr, restarts[[1L]])
where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 37: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 40: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 41: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), knn = 1L, metric = "L2",
nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertIntegerish(knn, lower = 1L, upper = nrow(fdata), len = 1)
assertChoice(metric, choices = metricChoices())
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, knn = knn, metric = metric, custom.metric = custom.metric,
nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKnn"
return(ret)
}
<bytecode: 0x55d51e8a7b30>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKnn in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 6. Error: Works with kernel / knn (@test_parallelComputeDistMat.R#22) ──────
the condition has length > 1
Backtrace:
1. classiFunc::classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L)
══ testthat results ═══════════════════════════════════════════════════════════
[ OK: 34 | SKIPPED: 0 | WARNINGS: 784 | FAILED: 6 ]
1. Error: classiKernel works for different Kernels (@test_classiKernel.R#34)
2. Error: classiKernel works for DTI data set (contains missing values) (@test_classiKernel.R#65)
3. Error: classiKnn works for phoneme data set from fda.usc package (@test_classiKnn.R#35)
4. Error: classiKnn works for DTI data set (contains missing values) (@test_classiKnn.R#103)
5. Error: classiKnn works for growth data set (contains irregular grid) (@test_classiKnn.R#132)
6. Error: Works with kernel / knn (@test_parallelComputeDistMat.R#22)
Error: testthat unit tests failed
Execution halted
Flavor: r-devel-linux-x86_64-debian-gcc
Version: 0.1.1
Check: tests
Result: ERROR
Running ‘testthat.R’ [22s/29s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
> library(testthat)
> library(classiFunc)
>
> test_check("classiFunc")
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKernel(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
ker = "Ker.norm", h = 50)
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKernel.R#34: classiKernel(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
ker = "Ker.norm", h = 50)
where 2: eval(code, test_env)
where 3: eval(code, test_env)
where 4: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 8: doTryCatch(return(expr), name, parentenv, handler)
where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 10: tryCatchList(expr, classes, parentenv, handlers)
where 11: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 12: test_code(desc, code, env = parent.frame())
where 13 at testthat/test_classiKernel.R#31: test_that("classiKernel works for different Kernels", {
data(phoneme, package = "fda.usc")
mod1 = classiKernel(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
ker = "Ker.norm", h = 50)
mod2 = classiKernel(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
h = 0.1, ker = "Ker.epa")
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE, nrows = nrow(mod1$fdata),
ncols = length(unique(mod1$classes)))
pred1.2 = predict(mod2, newdata = phoneme[["test"]]$dat,
predict.type = "prob")
pred2 = predict(mod2, newdata = phoneme[["test"]]$dat, predict.type = "response")
checkmate::expect_factor(pred2, any.missing = FALSE, levels = levels(phoneme[["classtest"]]))
})
where 14: eval(code, test_env)
where 15: eval(code, test_env)
where 16: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 17: doTryCatch(return(expr), name, parentenv, handler)
where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 20: doTryCatch(return(expr), name, parentenv, handler)
where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 22: tryCatchList(expr, classes, parentenv, handlers)
where 23: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 24: test_code(NULL, exprs, env)
where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 26: force(code)
where 27: doWithOneRestart(return(expr), restart)
where 28: withOneRestart(expr, restarts[[1L]])
where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 31: FUN(X[[i]], ...)
where 32: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 33: force(code)
where 34: doWithOneRestart(return(expr), restart)
where 35: withOneRestart(expr, restarts[[1L]])
where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 37: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 40: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 41: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), h = 1, metric = "L2",
ker = "Ker.norm", nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, custom.ker = function(u) {
return(dnorm(u))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertNumeric(h, lower = 0, len = 1L)
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
assertChoice(ker, choices = kerChoices())
assertChoice(metric, choices = metricChoices())
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !checkmate::anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
if (ker != "custom.ker")
custom.ker = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, h = h, metric = metric, ker = ker, custom.metric = custom.metric,
custom.ker = custom.ker, nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKernel"
return(ret)
}
<bytecode: 0xc1010b0>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKernel in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 1. Error: classiKernel works for different Kernels (@test_classiKernel.R#34)
the condition has length > 1
Backtrace:
1. classiFunc::classiKernel(...)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKernel(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKernel.R#65: classiKernel(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
where 3: withCallingHandlers(code, warning = function(condition) {
out$push(condition)
maybe_restart("muffleWarning")
})
where 4: .capture(act$val <- eval_bare(quo_get_expr(.quo), quo_get_env(.quo)),
...)
where 5: quasi_capture(enquo(object), label, capture_warnings)
where 6 at testthat/test_classiKernel.R#65: expect_warning({
mod1 = classiKernel(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
})
where 7: eval(code, test_env)
where 8: eval(code, test_env)
where 9: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 10: doTryCatch(return(expr), name, parentenv, handler)
where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 13: doTryCatch(return(expr), name, parentenv, handler)
where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 15: tryCatchList(expr, classes, parentenv, handlers)
where 16: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 17: test_code(desc, code, env = parent.frame())
where 18 at testthat/test_classiKernel.R#53: test_that("classiKernel works for DTI data set (contains missing values)",
{
data("DTI_original")
DTI = DTI_original
classes = DTI[, "case"]
set.seed(123)
train_inds = sample(1:nrow(DTI), size = 0.8 * nrow(DTI),
replace = FALSE)
test_inds = (1:nrow(DTI))[!(1:nrow(DTI)) %in% train_inds]
DTI = DTI[, !colnames(DTI) == "target"]
expect_warning({
mod1 = classiKernel(classes = classes[train_inds],
fdata = DTI[train_inds, "cca"])
})
expect_warning({
mod2 = classiKernel(classes = classes[train_inds],
fdata = DTI[train_inds, "cca"], h = 10000)
})
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(levels(mod1$classes)))
pred2 = predict(mod2, newdata = DTI[train_inds, "cca"],
predict.type = "prob")
checkmate::expect_matrix(pred2, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(levels(mod1$classes)))
pred3 = predict(mod2, newdata = DTI[train_inds, "cca"],
predict.type = "response")
checkmate::assert_true(all(pred3 == 1))
checkmate::expect_factor(pred3, any.missing = FALSE,
levels = levels(mod2$classes))
})
where 19: eval(code, test_env)
where 20: eval(code, test_env)
where 21: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 22: doTryCatch(return(expr), name, parentenv, handler)
where 23: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 24: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 25: doTryCatch(return(expr), name, parentenv, handler)
where 26: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 27: tryCatchList(expr, classes, parentenv, handlers)
where 28: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 29: test_code(NULL, exprs, env)
where 30: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 31: force(code)
where 32: doWithOneRestart(return(expr), restart)
where 33: withOneRestart(expr, restarts[[1L]])
where 34: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 35: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 36: FUN(X[[i]], ...)
where 37: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 38: force(code)
where 39: doWithOneRestart(return(expr), restart)
where 40: withOneRestart(expr, restarts[[1L]])
where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 42: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 43: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 44: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 45: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 46: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), h = 1, metric = "L2",
ker = "Ker.norm", nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, custom.ker = function(u) {
return(dnorm(u))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertNumeric(h, lower = 0, len = 1L)
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
assertChoice(ker, choices = kerChoices())
assertChoice(metric, choices = metricChoices())
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !checkmate::anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
if (ker != "custom.ker")
custom.ker = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, h = h, metric = metric, ker = ker, custom.metric = custom.metric,
custom.ker = custom.ker, nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKernel"
return(ret)
}
<bytecode: 0xc1010b0>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKernel in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 2. Error: classiKernel works for DTI data set (contains missing values) (@tes
the condition has length > 1
Backtrace:
1. testthat::expect_warning(...)
6. classiFunc::classiKernel(...)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data)
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKnn.R#35: classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data)
where 2: eval(code, test_env)
where 3: eval(code, test_env)
where 4: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 8: doTryCatch(return(expr), name, parentenv, handler)
where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 10: tryCatchList(expr, classes, parentenv, handlers)
where 11: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 12: test_code(desc, code, env = parent.frame())
where 13 at testthat/test_classiKnn.R#32: test_that("classiKnn works for phoneme data set from fda.usc package",
{
data(phoneme, package = "fda.usc")
mod1 = classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data)
mod2 = classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
nderiv = 1L, knn = 3L)
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(unique(mod1$classes)))
pred2 = predict(mod2, newdata = phoneme[["test"]]$dat,
predict.type = "response")
checkmate::expect_factor(pred2, any.missing = FALSE,
levels = levels(phoneme[["classtest"]]))
})
where 14: eval(code, test_env)
where 15: eval(code, test_env)
where 16: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 17: doTryCatch(return(expr), name, parentenv, handler)
where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 20: doTryCatch(return(expr), name, parentenv, handler)
where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 22: tryCatchList(expr, classes, parentenv, handlers)
where 23: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 24: test_code(NULL, exprs, env)
where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 26: force(code)
where 27: doWithOneRestart(return(expr), restart)
where 28: withOneRestart(expr, restarts[[1L]])
where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 31: FUN(X[[i]], ...)
where 32: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 33: force(code)
where 34: doWithOneRestart(return(expr), restart)
where 35: withOneRestart(expr, restarts[[1L]])
where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 37: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 40: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 41: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), knn = 1L, metric = "L2",
nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertIntegerish(knn, lower = 1L, upper = nrow(fdata), len = 1)
assertChoice(metric, choices = metricChoices())
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, knn = knn, metric = metric, custom.metric = custom.metric,
nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKnn"
return(ret)
}
<bytecode: 0xc10af20>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKnn in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 3. Error: classiKnn works for phoneme data set from fda.usc package (@test_cl
the condition has length > 1
Backtrace:
1. classiFunc::classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKnn.R#103: classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
where 3: withCallingHandlers(code, warning = function(condition) {
out$push(condition)
maybe_restart("muffleWarning")
})
where 4: .capture(act$val <- eval_bare(quo_get_expr(.quo), quo_get_env(.quo)),
...)
where 5: quasi_capture(enquo(object), label, capture_warnings)
where 6 at testthat/test_classiKnn.R#103: expect_warning({
mod1 = classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
})
where 7: eval(code, test_env)
where 8: eval(code, test_env)
where 9: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 10: doTryCatch(return(expr), name, parentenv, handler)
where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 13: doTryCatch(return(expr), name, parentenv, handler)
where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 15: tryCatchList(expr, classes, parentenv, handlers)
where 16: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 17: test_code(desc, code, env = parent.frame())
where 18 at testthat/test_classiKnn.R#91: test_that("classiKnn works for DTI data set (contains missing values)",
{
data("DTI_original")
DTI = DTI_original
classes = DTI[, "case"]
set.seed(123)
train_inds = sample(1:nrow(DTI), size = 0.8 * nrow(DTI),
replace = FALSE)
test_inds = (1:nrow(DTI))[!(1:nrow(DTI)) %in% train_inds]
DTI = DTI[, !colnames(DTI) == "target"]
expect_warning({
mod1 = classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
})
expect_warning({
mod2 = classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"], nderiv = 1L, knn = 3L)
})
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(levels(mod1$classes)))
pred2 = predict(mod2, newdata = DTI[train_inds, "cca"],
predict.type = "response")
checkmate::expect_factor(pred2, any.missing = FALSE,
levels = levels(mod2$classes))
pred3 = predict(mod2, newdata = DTI[1, "cca"], predict.type = "response")
checkmate::expect_factor(pred3, any.missing = FALSE,
levels = levels(mod2$classes))
})
where 19: eval(code, test_env)
where 20: eval(code, test_env)
where 21: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 22: doTryCatch(return(expr), name, parentenv, handler)
where 23: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 24: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 25: doTryCatch(return(expr), name, parentenv, handler)
where 26: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 27: tryCatchList(expr, classes, parentenv, handlers)
where 28: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 29: test_code(NULL, exprs, env)
where 30: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 31: force(code)
where 32: doWithOneRestart(return(expr), restart)
where 33: withOneRestart(expr, restarts[[1L]])
where 34: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 35: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 36: FUN(X[[i]], ...)
where 37: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 38: force(code)
where 39: doWithOneRestart(return(expr), restart)
where 40: withOneRestart(expr, restarts[[1L]])
where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 42: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 43: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 44: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 45: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 46: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), knn = 1L, metric = "L2",
nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertIntegerish(knn, lower = 1L, upper = nrow(fdata), len = 1)
assertChoice(metric, choices = metricChoices())
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, knn = knn, metric = metric, custom.metric = custom.metric,
nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKnn"
return(ret)
}
<bytecode: 0xc10af20>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKnn in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 4. Error: classiKnn works for DTI data set (contains missing values) (@test_c
the condition has length > 1
Backtrace:
1. testthat::expect_warning(...)
6. classiFunc::classiKnn(...)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKnn(classes = classes[train_inds], grid = Growth$age_grid,
fdata = Growth$height[train_inds, ])
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKnn.R#132: classiKnn(classes = classes[train_inds], grid = Growth$age_grid,
fdata = Growth$height[train_inds, ])
where 2: eval(code, test_env)
where 3: eval(code, test_env)
where 4: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 8: doTryCatch(return(expr), name, parentenv, handler)
where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 10: tryCatchList(expr, classes, parentenv, handlers)
where 11: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 12: test_code(desc, code, env = parent.frame())
where 13 at testthat/test_classiKnn.R#122: test_that("classiKnn works for growth data set (contains irregular grid)",
{
data(Growth_irregular, package = "classiFunc")
Growth = Growth_irregular
classes = Growth$sex
set.seed(123)
train_inds = sample(1:length(classes), size = 0.8 * length(classes),
replace = FALSE)
test_inds = (1:length(classes))[!(1:length(classes)) %in%
train_inds]
mod1 = classiKnn(classes = classes[train_inds], grid = Growth$age_grid,
fdata = Growth$height[train_inds, ])
mod2 = classiKnn(classes = classes[train_inds], grid = Growth$age_grid,
fdata = Growth$height[train_inds, ], nderiv = 1L,
knn = 3L)
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(levels(mod1$classes)))
pred2 = predict(mod2, newdata = Growth$height[test_inds,
], predict.type = "response")
checkmate::expect_factor(pred2, any.missing = FALSE,
levels = levels(mod2$classes))
pred3 = predict(mod2, newdata = Growth$height[test_inds,
], predict.type = "response")
checkmate::expect_factor(pred3, any.missing = FALSE,
levels = levels(mod2$classes))
})
where 14: eval(code, test_env)
where 15: eval(code, test_env)
where 16: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 17: doTryCatch(return(expr), name, parentenv, handler)
where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 20: doTryCatch(return(expr), name, parentenv, handler)
where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 22: tryCatchList(expr, classes, parentenv, handlers)
where 23: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 24: test_code(NULL, exprs, env)
where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 26: force(code)
where 27: doWithOneRestart(return(expr), restart)
where 28: withOneRestart(expr, restarts[[1L]])
where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 31: FUN(X[[i]], ...)
where 32: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 33: force(code)
where 34: doWithOneRestart(return(expr), restart)
where 35: withOneRestart(expr, restarts[[1L]])
where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 37: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 40: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 41: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), knn = 1L, metric = "L2",
nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertIntegerish(knn, lower = 1L, upper = nrow(fdata), len = 1)
assertChoice(metric, choices = metricChoices())
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, knn = knn, metric = metric, custom.metric = custom.metric,
nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKnn"
return(ret)
}
<bytecode: 0xc10af20>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKnn in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 5. Error: classiKnn works for growth data set (contains irregular grid) (@tes
the condition has length > 1
Backtrace:
1. classiFunc::classiKnn(...)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L)
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_parallelComputeDistMat.R#22: classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L)
where 2: eval(code, test_env)
where 3: eval(code, test_env)
where 4: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 8: doTryCatch(return(expr), name, parentenv, handler)
where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 10: tryCatchList(expr, classes, parentenv, handlers)
where 11: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 12: test_code(desc, code, env = parent.frame())
where 13 at testthat/test_parallelComputeDistMat.R#17: test_that("Works with kernel / knn", {
set.seed(123)
trn = matrix(rnorm(n = 20), 5, byrow = TRUE)
tst = matrix(rnorm(n = 40), 10, byrow = TRUE)
mod = classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L)
pred = predict(mod, newdata = tst)
pred2 = predict(mod, newdata = tst, parallel = TRUE, batches = 2)
expect_true(all.equal(pred, pred2))
mod = classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L,
metric = "shortEuclidean", dmin = 0, dmax = 1/2)
pred = predict(mod, newdata = tst)
pred2 = predict(mod, newdata = tst, parallel = TRUE, batches = 2)
expect_true(all.equal(pred, pred2))
if (require("dtw")) {
mod = classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 2L,
metric = "dtw")
pred = predict(mod, newdata = tst)
expect_message({
pred2 = predict(mod, newdata = tst, parallel = TRUE,
batches = 3)
}, "Loading")
expect_true(all.equal(pred, pred2))
}
})
where 14: eval(code, test_env)
where 15: eval(code, test_env)
where 16: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 17: doTryCatch(return(expr), name, parentenv, handler)
where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 20: doTryCatch(return(expr), name, parentenv, handler)
where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 22: tryCatchList(expr, classes, parentenv, handlers)
where 23: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 24: test_code(NULL, exprs, env)
where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 26: force(code)
where 27: doWithOneRestart(return(expr), restart)
where 28: withOneRestart(expr, restarts[[1L]])
where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 31: FUN(X[[i]], ...)
where 32: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 33: force(code)
where 34: doWithOneRestart(return(expr), restart)
where 35: withOneRestart(expr, restarts[[1L]])
where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 37: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 40: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 41: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), knn = 1L, metric = "L2",
nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertIntegerish(knn, lower = 1L, upper = nrow(fdata), len = 1)
assertChoice(metric, choices = metricChoices())
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, knn = knn, metric = metric, custom.metric = custom.metric,
nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKnn"
return(ret)
}
<bytecode: 0xc10af20>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKnn in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 6. Error: Works with kernel / knn (@test_parallelComputeDistMat.R#22) ──────
the condition has length > 1
Backtrace:
1. classiFunc::classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L)
══ testthat results ═══════════════════════════════════════════════════════════
[ OK: 34 | SKIPPED: 0 | WARNINGS: 784 | FAILED: 6 ]
1. Error: classiKernel works for different Kernels (@test_classiKernel.R#34)
2. Error: classiKernel works for DTI data set (contains missing values) (@test_classiKernel.R#65)
3. Error: classiKnn works for phoneme data set from fda.usc package (@test_classiKnn.R#35)
4. Error: classiKnn works for DTI data set (contains missing values) (@test_classiKnn.R#103)
5. Error: classiKnn works for growth data set (contains irregular grid) (@test_classiKnn.R#132)
6. Error: Works with kernel / knn (@test_parallelComputeDistMat.R#22)
Error: testthat unit tests failed
Execution halted
Flavor: r-devel-linux-x86_64-fedora-clang
Version: 0.1.1
Check: tests
Result: ERROR
Running ‘testthat.R’ [23s/27s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
> library(testthat)
> library(classiFunc)
>
> test_check("classiFunc")
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKernel(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
ker = "Ker.norm", h = 50)
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKernel.R#34: classiKernel(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
ker = "Ker.norm", h = 50)
where 2: eval(code, test_env)
where 3: eval(code, test_env)
where 4: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 8: doTryCatch(return(expr), name, parentenv, handler)
where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 10: tryCatchList(expr, classes, parentenv, handlers)
where 11: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 12: test_code(desc, code, env = parent.frame())
where 13 at testthat/test_classiKernel.R#31: test_that("classiKernel works for different Kernels", {
data(phoneme, package = "fda.usc")
mod1 = classiKernel(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
ker = "Ker.norm", h = 50)
mod2 = classiKernel(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
h = 0.1, ker = "Ker.epa")
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE, nrows = nrow(mod1$fdata),
ncols = length(unique(mod1$classes)))
pred1.2 = predict(mod2, newdata = phoneme[["test"]]$dat,
predict.type = "prob")
pred2 = predict(mod2, newdata = phoneme[["test"]]$dat, predict.type = "response")
checkmate::expect_factor(pred2, any.missing = FALSE, levels = levels(phoneme[["classtest"]]))
})
where 14: eval(code, test_env)
where 15: eval(code, test_env)
where 16: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 17: doTryCatch(return(expr), name, parentenv, handler)
where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 20: doTryCatch(return(expr), name, parentenv, handler)
where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 22: tryCatchList(expr, classes, parentenv, handlers)
where 23: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 24: test_code(NULL, exprs, env)
where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 26: force(code)
where 27: doWithOneRestart(return(expr), restart)
where 28: withOneRestart(expr, restarts[[1L]])
where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 31: FUN(X[[i]], ...)
where 32: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 33: force(code)
where 34: doWithOneRestart(return(expr), restart)
where 35: withOneRestart(expr, restarts[[1L]])
where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 37: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 40: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 41: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), h = 1, metric = "L2",
ker = "Ker.norm", nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, custom.ker = function(u) {
return(dnorm(u))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertNumeric(h, lower = 0, len = 1L)
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
assertChoice(ker, choices = kerChoices())
assertChoice(metric, choices = metricChoices())
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !checkmate::anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
if (ker != "custom.ker")
custom.ker = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, h = h, metric = metric, ker = ker, custom.metric = custom.metric,
custom.ker = custom.ker, nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKernel"
return(ret)
}
<bytecode: 0xceceb58>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKernel in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 1. Error: classiKernel works for different Kernels (@test_classiKernel.R#34)
the condition has length > 1
Backtrace:
1. classiFunc::classiKernel(...)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKernel(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKernel.R#65: classiKernel(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
where 3: withCallingHandlers(code, warning = function(condition) {
out$push(condition)
maybe_restart("muffleWarning")
})
where 4: .capture(act$val <- eval_bare(quo_get_expr(.quo), quo_get_env(.quo)),
...)
where 5: quasi_capture(enquo(object), label, capture_warnings)
where 6 at testthat/test_classiKernel.R#65: expect_warning({
mod1 = classiKernel(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
})
where 7: eval(code, test_env)
where 8: eval(code, test_env)
where 9: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 10: doTryCatch(return(expr), name, parentenv, handler)
where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 13: doTryCatch(return(expr), name, parentenv, handler)
where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 15: tryCatchList(expr, classes, parentenv, handlers)
where 16: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 17: test_code(desc, code, env = parent.frame())
where 18 at testthat/test_classiKernel.R#53: test_that("classiKernel works for DTI data set (contains missing values)",
{
data("DTI_original")
DTI = DTI_original
classes = DTI[, "case"]
set.seed(123)
train_inds = sample(1:nrow(DTI), size = 0.8 * nrow(DTI),
replace = FALSE)
test_inds = (1:nrow(DTI))[!(1:nrow(DTI)) %in% train_inds]
DTI = DTI[, !colnames(DTI) == "target"]
expect_warning({
mod1 = classiKernel(classes = classes[train_inds],
fdata = DTI[train_inds, "cca"])
})
expect_warning({
mod2 = classiKernel(classes = classes[train_inds],
fdata = DTI[train_inds, "cca"], h = 10000)
})
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(levels(mod1$classes)))
pred2 = predict(mod2, newdata = DTI[train_inds, "cca"],
predict.type = "prob")
checkmate::expect_matrix(pred2, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(levels(mod1$classes)))
pred3 = predict(mod2, newdata = DTI[train_inds, "cca"],
predict.type = "response")
checkmate::assert_true(all(pred3 == 1))
checkmate::expect_factor(pred3, any.missing = FALSE,
levels = levels(mod2$classes))
})
where 19: eval(code, test_env)
where 20: eval(code, test_env)
where 21: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 22: doTryCatch(return(expr), name, parentenv, handler)
where 23: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 24: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 25: doTryCatch(return(expr), name, parentenv, handler)
where 26: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 27: tryCatchList(expr, classes, parentenv, handlers)
where 28: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 29: test_code(NULL, exprs, env)
where 30: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 31: force(code)
where 32: doWithOneRestart(return(expr), restart)
where 33: withOneRestart(expr, restarts[[1L]])
where 34: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 35: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 36: FUN(X[[i]], ...)
where 37: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 38: force(code)
where 39: doWithOneRestart(return(expr), restart)
where 40: withOneRestart(expr, restarts[[1L]])
where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 42: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 43: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 44: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 45: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 46: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), h = 1, metric = "L2",
ker = "Ker.norm", nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, custom.ker = function(u) {
return(dnorm(u))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertNumeric(h, lower = 0, len = 1L)
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
assertChoice(ker, choices = kerChoices())
assertChoice(metric, choices = metricChoices())
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !checkmate::anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
if (ker != "custom.ker")
custom.ker = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, h = h, metric = metric, ker = ker, custom.metric = custom.metric,
custom.ker = custom.ker, nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKernel"
return(ret)
}
<bytecode: 0xceceb58>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKernel in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 2. Error: classiKernel works for DTI data set (contains missing values) (@tes
the condition has length > 1
Backtrace:
1. testthat::expect_warning(...)
6. classiFunc::classiKernel(...)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data)
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKnn.R#35: classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data)
where 2: eval(code, test_env)
where 3: eval(code, test_env)
where 4: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 8: doTryCatch(return(expr), name, parentenv, handler)
where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 10: tryCatchList(expr, classes, parentenv, handlers)
where 11: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 12: test_code(desc, code, env = parent.frame())
where 13 at testthat/test_classiKnn.R#32: test_that("classiKnn works for phoneme data set from fda.usc package",
{
data(phoneme, package = "fda.usc")
mod1 = classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data)
mod2 = classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data,
nderiv = 1L, knn = 3L)
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(unique(mod1$classes)))
pred2 = predict(mod2, newdata = phoneme[["test"]]$dat,
predict.type = "response")
checkmate::expect_factor(pred2, any.missing = FALSE,
levels = levels(phoneme[["classtest"]]))
})
where 14: eval(code, test_env)
where 15: eval(code, test_env)
where 16: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 17: doTryCatch(return(expr), name, parentenv, handler)
where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 20: doTryCatch(return(expr), name, parentenv, handler)
where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 22: tryCatchList(expr, classes, parentenv, handlers)
where 23: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 24: test_code(NULL, exprs, env)
where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 26: force(code)
where 27: doWithOneRestart(return(expr), restart)
where 28: withOneRestart(expr, restarts[[1L]])
where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 31: FUN(X[[i]], ...)
where 32: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 33: force(code)
where 34: doWithOneRestart(return(expr), restart)
where 35: withOneRestart(expr, restarts[[1L]])
where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 37: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 40: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 41: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), knn = 1L, metric = "L2",
nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertIntegerish(knn, lower = 1L, upper = nrow(fdata), len = 1)
assertChoice(metric, choices = metricChoices())
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, knn = knn, metric = metric, custom.metric = custom.metric,
nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKnn"
return(ret)
}
<bytecode: 0xcf47ae8>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKnn in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 3. Error: classiKnn works for phoneme data set from fda.usc package (@test_cl
the condition has length > 1
Backtrace:
1. classiFunc::classiKnn(classes = phoneme[["classlearn"]], fdata = phoneme[["learn"]]$data)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKnn.R#103: classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
where 3: withCallingHandlers(code, warning = function(condition) {
out$push(condition)
maybe_restart("muffleWarning")
})
where 4: .capture(act$val <- eval_bare(quo_get_expr(.quo), quo_get_env(.quo)),
...)
where 5: quasi_capture(enquo(object), label, capture_warnings)
where 6 at testthat/test_classiKnn.R#103: expect_warning({
mod1 = classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
})
where 7: eval(code, test_env)
where 8: eval(code, test_env)
where 9: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 10: doTryCatch(return(expr), name, parentenv, handler)
where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 13: doTryCatch(return(expr), name, parentenv, handler)
where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 15: tryCatchList(expr, classes, parentenv, handlers)
where 16: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 17: test_code(desc, code, env = parent.frame())
where 18 at testthat/test_classiKnn.R#91: test_that("classiKnn works for DTI data set (contains missing values)",
{
data("DTI_original")
DTI = DTI_original
classes = DTI[, "case"]
set.seed(123)
train_inds = sample(1:nrow(DTI), size = 0.8 * nrow(DTI),
replace = FALSE)
test_inds = (1:nrow(DTI))[!(1:nrow(DTI)) %in% train_inds]
DTI = DTI[, !colnames(DTI) == "target"]
expect_warning({
mod1 = classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"])
})
expect_warning({
mod2 = classiKnn(classes = classes[train_inds], fdata = DTI[train_inds,
"cca"], nderiv = 1L, knn = 3L)
})
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(levels(mod1$classes)))
pred2 = predict(mod2, newdata = DTI[train_inds, "cca"],
predict.type = "response")
checkmate::expect_factor(pred2, any.missing = FALSE,
levels = levels(mod2$classes))
pred3 = predict(mod2, newdata = DTI[1, "cca"], predict.type = "response")
checkmate::expect_factor(pred3, any.missing = FALSE,
levels = levels(mod2$classes))
})
where 19: eval(code, test_env)
where 20: eval(code, test_env)
where 21: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 22: doTryCatch(return(expr), name, parentenv, handler)
where 23: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 24: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 25: doTryCatch(return(expr), name, parentenv, handler)
where 26: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 27: tryCatchList(expr, classes, parentenv, handlers)
where 28: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 29: test_code(NULL, exprs, env)
where 30: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 31: force(code)
where 32: doWithOneRestart(return(expr), restart)
where 33: withOneRestart(expr, restarts[[1L]])
where 34: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 35: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 36: FUN(X[[i]], ...)
where 37: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 38: force(code)
where 39: doWithOneRestart(return(expr), restart)
where 40: withOneRestart(expr, restarts[[1L]])
where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 42: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 43: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 44: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 45: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 46: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), knn = 1L, metric = "L2",
nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertIntegerish(knn, lower = 1L, upper = nrow(fdata), len = 1)
assertChoice(metric, choices = metricChoices())
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, knn = knn, metric = metric, custom.metric = custom.metric,
nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKnn"
return(ret)
}
<bytecode: 0xcf47ae8>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKnn in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 4. Error: classiKnn works for DTI data set (contains missing values) (@test_c
the condition has length > 1
Backtrace:
1. testthat::expect_warning(...)
6. classiFunc::classiKnn(...)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKnn(classes = classes[train_inds], grid = Growth$age_grid,
fdata = Growth$height[train_inds, ])
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_classiKnn.R#132: classiKnn(classes = classes[train_inds], grid = Growth$age_grid,
fdata = Growth$height[train_inds, ])
where 2: eval(code, test_env)
where 3: eval(code, test_env)
where 4: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 8: doTryCatch(return(expr), name, parentenv, handler)
where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 10: tryCatchList(expr, classes, parentenv, handlers)
where 11: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 12: test_code(desc, code, env = parent.frame())
where 13 at testthat/test_classiKnn.R#122: test_that("classiKnn works for growth data set (contains irregular grid)",
{
data(Growth_irregular, package = "classiFunc")
Growth = Growth_irregular
classes = Growth$sex
set.seed(123)
train_inds = sample(1:length(classes), size = 0.8 * length(classes),
replace = FALSE)
test_inds = (1:length(classes))[!(1:length(classes)) %in%
train_inds]
mod1 = classiKnn(classes = classes[train_inds], grid = Growth$age_grid,
fdata = Growth$height[train_inds, ])
mod2 = classiKnn(classes = classes[train_inds], grid = Growth$age_grid,
fdata = Growth$height[train_inds, ], nderiv = 1L,
knn = 3L)
pred1 = predict(mod1, predict.type = "prob")
checkmate::expect_matrix(pred1, any.missing = FALSE,
nrows = nrow(mod1$fdata), ncols = length(levels(mod1$classes)))
pred2 = predict(mod2, newdata = Growth$height[test_inds,
], predict.type = "response")
checkmate::expect_factor(pred2, any.missing = FALSE,
levels = levels(mod2$classes))
pred3 = predict(mod2, newdata = Growth$height[test_inds,
], predict.type = "response")
checkmate::expect_factor(pred3, any.missing = FALSE,
levels = levels(mod2$classes))
})
where 14: eval(code, test_env)
where 15: eval(code, test_env)
where 16: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 17: doTryCatch(return(expr), name, parentenv, handler)
where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 20: doTryCatch(return(expr), name, parentenv, handler)
where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 22: tryCatchList(expr, classes, parentenv, handlers)
where 23: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 24: test_code(NULL, exprs, env)
where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 26: force(code)
where 27: doWithOneRestart(return(expr), restart)
where 28: withOneRestart(expr, restarts[[1L]])
where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 31: FUN(X[[i]], ...)
where 32: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 33: force(code)
where 34: doWithOneRestart(return(expr), restart)
where 35: withOneRestart(expr, restarts[[1L]])
where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 37: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 40: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 41: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), knn = 1L, metric = "L2",
nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertIntegerish(knn, lower = 1L, upper = nrow(fdata), len = 1)
assertChoice(metric, choices = metricChoices())
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, knn = knn, metric = metric, custom.metric = custom.metric,
nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKnn"
return(ret)
}
<bytecode: 0xcf47ae8>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKnn in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 5. Error: classiKnn works for growth data set (contains irregular grid) (@tes
the condition has length > 1
Backtrace:
1. classiFunc::classiKnn(...)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
classiFunc
--- call from context ---
classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L)
--- call from argument ---
if (class(fdata) == "data.frame") fdata = as.matrix(fdata)
--- R stacktrace ---
where 1 at testthat/test_parallelComputeDistMat.R#22: classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L)
where 2: eval(code, test_env)
where 3: eval(code, test_env)
where 4: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 5: doTryCatch(return(expr), name, parentenv, handler)
where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 8: doTryCatch(return(expr), name, parentenv, handler)
where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 10: tryCatchList(expr, classes, parentenv, handlers)
where 11: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 12: test_code(desc, code, env = parent.frame())
where 13 at testthat/test_parallelComputeDistMat.R#17: test_that("Works with kernel / knn", {
set.seed(123)
trn = matrix(rnorm(n = 20), 5, byrow = TRUE)
tst = matrix(rnorm(n = 40), 10, byrow = TRUE)
mod = classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L)
pred = predict(mod, newdata = tst)
pred2 = predict(mod, newdata = tst, parallel = TRUE, batches = 2)
expect_true(all.equal(pred, pred2))
mod = classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L,
metric = "shortEuclidean", dmin = 0, dmax = 1/2)
pred = predict(mod, newdata = tst)
pred2 = predict(mod, newdata = tst, parallel = TRUE, batches = 2)
expect_true(all.equal(pred, pred2))
if (require("dtw")) {
mod = classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 2L,
metric = "dtw")
pred = predict(mod, newdata = tst)
expect_message({
pred2 = predict(mod, newdata = tst, parallel = TRUE,
batches = 3)
}, "Loading")
expect_true(all.equal(pred, pred2))
}
})
where 14: eval(code, test_env)
where 15: eval(code, test_env)
where 16: withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error)
where 17: doTryCatch(return(expr), name, parentenv, handler)
where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
where 20: doTryCatch(return(expr), name, parentenv, handler)
where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
names[nh], parentenv, handlers[[nh]])
where 22: tryCatchList(expr, classes, parentenv, handlers)
where 23: tryCatch(withCallingHandlers({
eval(code, test_env)
if (!handled && !is.null(test)) {
skip_empty()
}
}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,
message = handle_message, error = handle_error), error = handle_fatal,
skip = function(e) {
})
where 24: test_code(NULL, exprs, env)
where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
where 26: force(code)
where 27: doWithOneRestart(return(expr), restart)
where 28: withOneRestart(expr, restarts[[1L]])
where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter,
{
reporter$start_file(basename(path))
lister$start_file(basename(path))
source_file(path, new.env(parent = env), chdir = TRUE,
wrap = wrap)
reporter$.end_context()
reporter$end_file()
})
where 31: FUN(X[[i]], ...)
where 32: lapply(paths, test_file, env = env, reporter = current_reporter,
start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
where 33: force(code)
where 34: doWithOneRestart(return(expr), restart)
where 35: withOneRestart(expr, restarts[[1L]])
where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
where 37: with_reporter(reporter = current_reporter, results <- lapply(paths,
test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE,
load_helpers = FALSE, wrap = wrap))
where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter,
..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,
wrap = wrap)
where 40: test_package_dir(package = package, test_path = test_path, filter = filter,
reporter = reporter, ..., stop_on_failure = stop_on_failure,
stop_on_warning = stop_on_warning, wrap = wrap)
where 41: test_check("classiFunc")
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (classes, fdata, grid = 1:ncol(fdata), knn = 1L, metric = "L2",
nderiv = 0L, derived = FALSE, deriv.method = "base.diff",
custom.metric = function(x, y, ...) {
return(sqrt(sum((x - y)^2)))
}, ...)
{
if (class(fdata) == "data.frame")
fdata = as.matrix(fdata)
assert_numeric(fdata)
assertClass(fdata, "matrix")
if (is.numeric(classes))
classes = factor(classes)
assertFactor(classes, any.missing = FALSE, len = nrow(fdata))
assertNumeric(grid, any.missing = FALSE, len = ncol(fdata))
assertIntegerish(knn, lower = 1L, upper = nrow(fdata), len = 1)
assertChoice(metric, choices = metricChoices())
assertIntegerish(nderiv, lower = 0L)
assertFlag(derived)
assertChoice(deriv.method, c("base.diff", "fda.deriv.fd"))
evenly.spaced = isTRUE(all.equal(grid, seq(grid[1], grid[length(grid)],
length.out = length(grid)), check.attributes = FALSE))
no.missing = !anyMissing(fdata)
if (!no.missing) {
warning("There are missing values in fdata. They will be filled using a spline representation!")
}
this.fdataTransform = fdataTransform(grid = grid, nderiv = nderiv,
derived = derived, evenly.spaced = evenly.spaced, no.missing = no.missing,
deriv.method = deriv.method, ...)
proc.fdata = this.fdataTransform(fdata)
if (metric != "custom.metric")
custom.metric = character(0)
ret = list(classes = classes, fdata = fdata, proc.fdata = proc.fdata,
grid = grid, knn = knn, metric = metric, custom.metric = custom.metric,
nderiv = nderiv, this.fdataTransform = this.fdataTransform,
call = as.list(match.call(expand.dots = FALSE)))
class(ret) = "classiKnn"
return(ret)
}
<bytecode: 0xcf47ae8>
<environment: namespace:classiFunc>
--- function search by body ---
Function classiKnn in namespace classiFunc has this body.
----------- END OF FAILURE REPORT --------------
── 6. Error: Works with kernel / knn (@test_parallelComputeDistMat.R#22) ──────
the condition has length > 1
Backtrace:
1. classiFunc::classiKnn(c(1, 1, 2, 2, 1), fdata = trn, knn = 1L)
══ testthat results ═══════════════════════════════════════════════════════════
[ OK: 34 | SKIPPED: 0 | WARNINGS: 784 | FAILED: 6 ]
1. Error: classiKernel works for different Kernels (@test_classiKernel.R#34)
2. Error: classiKernel works for DTI data set (contains missing values) (@test_classiKernel.R#65)
3. Error: classiKnn works for phoneme data set from fda.usc package (@test_classiKnn.R#35)
4. Error: classiKnn works for DTI data set (contains missing values) (@test_classiKnn.R#103)
5. Error: classiKnn works for growth data set (contains irregular grid) (@test_classiKnn.R#132)
6. Error: Works with kernel / knn (@test_parallelComputeDistMat.R#22)
Error: testthat unit tests failed
Execution halted
Flavor: r-devel-linux-x86_64-fedora-gcc
Version: 0.1.1
Check: tests
Result: ERROR
Running ‘testthat.R’ [34s/44s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
> library(testthat)
> library(classiFunc)
>
> test_check("classiFunc")
── 1. Failure: computeDistMat works rucrdtw metrics (@test_computeDistMat.R#100)
all(as.vector(dist1) <= as.vector(dist3)) isn't true.
══ testthat results ═══════════════════════════════════════════════════════════
[ OK: 54 | SKIPPED: 0 | WARNINGS: 780 | FAILED: 1 ]
1. Failure: computeDistMat works rucrdtw metrics (@test_computeDistMat.R#100)
Error: testthat unit tests failed
Execution halted
Flavor: r-patched-solaris-x86