Running ‘testthat.R’ [24s/44s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(lmvar)
  > 
  > test_check("lmvar")
  ── 1. Error: print.cvlmvar works correctly (@test_cross_validations.R#158)  ────
  2 nodes produced errors; first error: the condition has length > 1
  1: cv.lmvar(fit, max_cores = 2) at testthat/test_cross_validations.R:158
  2: parallel::parLapply(cl, 1:k, function(i) {
         foldrows = is.element(1:length(y), selected_obs[i, ])
         if (is.null(X_mu)) {
             XX = NULL
             XX_predict = matrix(1, nrow = sum(foldrows), ncol = 1)
         }
         else {
             XX = X_mu[!foldrows, ]
             XX = matrix_as_matrix(XX, colnames(X_mu))
             XX = make_matrix_full_rank(XX)
             XX_predict = X_mu[foldrows, colnames(XX)]
             XX_predict = matrix_as_matrix(XX_predict, colnames(XX))
         }
         if (is.null(X_sigma)) {
             XX_sigma = NULL
             XX_sigma_predict = matrix(1, nrow = sum(foldrows), ncol = 1)
         }
         else {
             XX_sigma = X_sigma[!foldrows, ]
             XX_sigma = matrix_as_matrix(XX_sigma, colnames(X_sigma))
             XX_sigma = make_matrix_full_rank(XX_sigma)
             XX_sigma_predict = X_sigma[foldrows, colnames(XX_sigma)]
             XX_sigma_predict = matrix_as_matrix(XX_sigma_predict, colnames(XX_sigma))
         }
         fit = tryCatch(lmvar(y[!foldrows], XX, XX_sigma, intercept_mu = intercept_mu, 
             intercept_sigma = intercept_sigma, sigma_min = sigma_min, slvr_options = slvr_options, 
             control = control), error = function(e) {
             outlist = list(error = e, warning = NULL, y = y[!foldrows], X_mu = XX, X_sigma = XX_sigma, 
                 intercept_mu = intercept_mu, intercept_sigma = intercept_sigma, sigma_min = sigma_min, 
                 slvr_options = slvr_options, control = control, training_rows = which(!foldrows))
             class(outlist) = "error_fit"
             return(outlist)
         }, warning = function(w) {
             outlist = list(error = NULL, warning = w, y = y[!foldrows], X_mu = XX, X_sigma = XX_sigma, 
                 intercept_mu = intercept_mu, intercept_sigma = intercept_sigma, sigma_min = sigma_min, 
                 slvr_options = slvr_options, control = control, training_rows = which(!foldrows))
             class(outlist) = "error_fit"
             return(outlist)
         })
         if (class(fit) == "error_fit") {
             return(fit)
         }
         predictions = predict.lmvar(fit, XX_predict, XX_sigma_predict, log = FALSE)
         mu_not_log = predictions[, "mu"]
         sigma_not_log = predictions[, "sigma"]
         if (log) {
             predictions = predict.lmvar(fit, XX_predict, XX_sigma_predict, log = log)
             mu = predictions[, "mu"]
             sigma = predictions[, "sigma"]
         }
         else {
             mu = mu_not_log
             sigma = sigma_not_log
         }
         if (log) {
             mae = abs(exp(y[foldrows]) - mu)
         }
         else {
             mae = abs(y[foldrows] - mu)
         }
         mse = mae^2
         excluded_foldrows = excluded_rows[foldrows]
         mae = mae[!excluded_foldrows]
         mse = mse[!excluded_foldrows]
         if (ks_test) {
             z = (y[foldrows] - mu_not_log)/sigma_not_log
             ks = tryCatch(stats::ks.test(z, "pnorm"), warning = function(w) {
                 warning(w)
                 dup = duplicated(z)
                 if (sum(dup) > 0) {
                     dup = which(dup)[1]
                     dup = which(z == z[dup])
                     dup = which(foldrows)[dup]
                     ks = suppressWarnings(stats::ks.test(z, "pnorm"))
                     outlist = list(warning = w, duplicates = dup, statistic = ks$statistic, 
                       p.value = ks$p.value)
                     class(outlist) = "error_ks"
                     return(outlist)
                 }
             })
         }
         if (isFunc) {
             rows = foldrows & !excluded_rows
             f_user = tryCatch(fun(fit, y[rows], object$X_mu[rows, ], object$X_sigma[rows, 
                 ]), error = function(e) {
                 outlist = list(error = e)
                 class(outlist) = "error_func"
                 return(outlist)
             })
         }
         outlist = list(mae = mean(mae), mse = mean(mse), mse_sqrt = sqrt(mean(mse)))
         if (ks_test) {
             outlist$ks = ks
         }
         if (isFunc) {
             outlist$fun = f_user
         }
         return(outlist)
     })
  3: do.call(c, clusterApply(cl = cl, x = splitList(X, nchunks), fun = lapply, FUN = fun, 
         ...), quote = TRUE)
  4: clusterApply(cl = cl, x = splitList(X, nchunks), fun = lapply, FUN = fun, ...)
  5: staticClusterApply(cl, fun, length(x), argfun)
  6: checkForRemoteErrors(val)
  7: stop(count, " nodes produced errors; first error: ", firstmsg, domain = NA)
  
  ── 2. Failure: cv.lmvar works with class Matrix (@test_cross_validations.R#175) 
  `capture.output(cv.lmvar(fit_Matrix, max_cores = 2))` threw an error.
  Message: 2 nodes produced errors; first error: the condition has length > 1
  Class:   simpleError/error/condition
  
  ── 3. Error: cv.lmvar error handling works (@test_cross_validations.R#275)  ────
  2 nodes produced errors; first error: the condition has length > 1
  1: expect_warning(cv.lmvar(fit, fun = error_function, max_cores = 2)) at testthat/test_cross_validations.R:275
  2: quasi_capture(enquo(object), capture_warnings, label = label)
  3: capture(act$val <- eval_bare(get_expr(quo), get_env(quo)))
  4: withCallingHandlers(code, warning = function(condition) {
         out$push(condition)
         invokeRestart("muffleWarning")
     })
  5: eval_bare(get_expr(quo), get_env(quo))
  6: cv.lmvar(fit, fun = error_function, max_cores = 2)
  7: parallel::parLapply(cl, 1:k, function(i) {
         foldrows = is.element(1:length(y), selected_obs[i, ])
         if (is.null(X_mu)) {
             XX = NULL
             XX_predict = matrix(1, nrow = sum(foldrows), ncol = 1)
         }
         else {
             XX = X_mu[!foldrows, ]
             XX = matrix_as_matrix(XX, colnames(X_mu))
             XX = make_matrix_full_rank(XX)
             XX_predict = X_mu[foldrows, colnames(XX)]
             XX_predict = matrix_as_matrix(XX_predict, colnames(XX))
         }
         if (is.null(X_sigma)) {
             XX_sigma = NULL
             XX_sigma_predict = matrix(1, nrow = sum(foldrows), ncol = 1)
         }
         else {
             XX_sigma = X_sigma[!foldrows, ]
             XX_sigma = matrix_as_matrix(XX_sigma, colnames(X_sigma))
             XX_sigma = make_matrix_full_rank(XX_sigma)
             XX_sigma_predict = X_sigma[foldrows, colnames(XX_sigma)]
             XX_sigma_predict = matrix_as_matrix(XX_sigma_predict, colnames(XX_sigma))
         }
         fit = tryCatch(lmvar(y[!foldrows], XX, XX_sigma, intercept_mu = intercept_mu, 
             intercept_sigma = intercept_sigma, sigma_min = sigma_min, slvr_options = slvr_options, 
             control = control), error = function(e) {
             outlist = list(error = e, warning = NULL, y = y[!foldrows], X_mu = XX, X_sigma = XX_sigma, 
                 intercept_mu = intercept_mu, intercept_sigma = intercept_sigma, sigma_min = sigma_min, 
                 slvr_options = slvr_options, control = control, training_rows = which(!foldrows))
             class(outlist) = "error_fit"
             return(outlist)
         }, warning = function(w) {
             outlist = list(error = NULL, warning = w, y = y[!foldrows], X_mu = XX, X_sigma = XX_sigma, 
                 intercept_mu = intercept_mu, intercept_sigma = intercept_sigma, sigma_min = sigma_min, 
                 slvr_options = slvr_options, control = control, training_rows = which(!foldrows))
             class(outlist) = "error_fit"
             return(outlist)
         })
         if (class(fit) == "error_fit") {
             return(fit)
         }
         predictions = predict.lmvar(fit, XX_predict, XX_sigma_predict, log = FALSE)
         mu_not_log = predictions[, "mu"]
         sigma_not_log = predictions[, "sigma"]
         if (log) {
             predictions = predict.lmvar(fit, XX_predict, XX_sigma_predict, log = log)
             mu = predictions[, "mu"]
             sigma = predictions[, "sigma"]
         }
         else {
             mu = mu_not_log
             sigma = sigma_not_log
         }
         if (log) {
             mae = abs(exp(y[foldrows]) - mu)
         }
         else {
             mae = abs(y[foldrows] - mu)
         }
         mse = mae^2
         excluded_foldrows = excluded_rows[foldrows]
         mae = mae[!excluded_foldrows]
         mse = mse[!excluded_foldrows]
         if (ks_test) {
             z = (y[foldrows] - mu_not_log)/sigma_not_log
             ks = tryCatch(stats::ks.test(z, "pnorm"), warning = function(w) {
                 warning(w)
                 dup = duplicated(z)
                 if (sum(dup) > 0) {
                     dup = which(dup)[1]
                     dup = which(z == z[dup])
                     dup = which(foldrows)[dup]
                     ks = suppressWarnings(stats::ks.test(z, "pnorm"))
                     outlist = list(warning = w, duplicates = dup, statistic = ks$statistic, 
                       p.value = ks$p.value)
                     class(outlist) = "error_ks"
                     return(outlist)
                 }
             })
         }
         if (isFunc) {
             rows = foldrows & !excluded_rows
             f_user = tryCatch(fun(fit, y[rows], object$X_mu[rows, ], object$X_sigma[rows, 
                 ]), error = function(e) {
                 outlist = list(error = e)
                 class(outlist) = "error_func"
                 return(outlist)
             })
         }
         outlist = list(mae = mean(mae), mse = mean(mse), mse_sqrt = sqrt(mean(mse)))
         if (ks_test) {
             outlist$ks = ks
         }
         if (isFunc) {
             outlist$fun = f_user
         }
         return(outlist)
     })
  8: do.call(c, clusterApply(cl = cl, x = splitList(X, nchunks), fun = lapply, FUN = fun, 
         ...), quote = TRUE)
  9: clusterApply(cl = cl, x = splitList(X, nchunks), fun = lapply, FUN = fun, ...)
  10: staticClusterApply(cl, fun, length(x), argfun)
  11: checkForRemoteErrors(val)
  12: stop(count, " nodes produced errors; first error: ", firstmsg, domain = NA)
  
  ── 4. Error: cv.lmvar works with model matrix with one column (@test_cross_valid
  2 nodes produced errors; first error: the condition has length > 1
  1: cv.lmvar(fit_test, seed = 3456, max_cores = 2) at testthat/test_cross_validations.R:307
  2: parallel::parLapply(cl, 1:k, function(i) {
         foldrows = is.element(1:length(y), selected_obs[i, ])
         if (is.null(X_mu)) {
             XX = NULL
             XX_predict = matrix(1, nrow = sum(foldrows), ncol = 1)
         }
         else {
             XX = X_mu[!foldrows, ]
             XX = matrix_as_matrix(XX, colnames(X_mu))
             XX = make_matrix_full_rank(XX)
             XX_predict = X_mu[foldrows, colnames(XX)]
             XX_predict = matrix_as_matrix(XX_predict, colnames(XX))
         }
         if (is.null(X_sigma)) {
             XX_sigma = NULL
             XX_sigma_predict = matrix(1, nrow = sum(foldrows), ncol = 1)
         }
         else {
             XX_sigma = X_sigma[!foldrows, ]
             XX_sigma = matrix_as_matrix(XX_sigma, colnames(X_sigma))
             XX_sigma = make_matrix_full_rank(XX_sigma)
             XX_sigma_predict = X_sigma[foldrows, colnames(XX_sigma)]
             XX_sigma_predict = matrix_as_matrix(XX_sigma_predict, colnames(XX_sigma))
         }
         fit = tryCatch(lmvar(y[!foldrows], XX, XX_sigma, intercept_mu = intercept_mu, 
             intercept_sigma = intercept_sigma, sigma_min = sigma_min, slvr_options = slvr_options, 
             control = control), error = function(e) {
             outlist = list(error = e, warning = NULL, y = y[!foldrows], X_mu = XX, X_sigma = XX_sigma, 
                 intercept_mu = intercept_mu, intercept_sigma = intercept_sigma, sigma_min = sigma_min, 
                 slvr_options = slvr_options, control = control, training_rows = which(!foldrows))
             class(outlist) = "error_fit"
             return(outlist)
         }, warning = function(w) {
             outlist = list(error = NULL, warning = w, y = y[!foldrows], X_mu = XX, X_sigma = XX_sigma, 
                 intercept_mu = intercept_mu, intercept_sigma = intercept_sigma, sigma_min = sigma_min, 
                 slvr_options = slvr_options, control = control, training_rows = which(!foldrows))
             class(outlist) = "error_fit"
             return(outlist)
         })
         if (class(fit) == "error_fit") {
             return(fit)
         }
         predictions = predict.lmvar(fit, XX_predict, XX_sigma_predict, log = FALSE)
         mu_not_log = predictions[, "mu"]
         sigma_not_log = predictions[, "sigma"]
         if (log) {
             predictions = predict.lmvar(fit, XX_predict, XX_sigma_predict, log = log)
             mu = predictions[, "mu"]
             sigma = predictions[, "sigma"]
         }
         else {
             mu = mu_not_log
             sigma = sigma_not_log
         }
         if (log) {
             mae = abs(exp(y[foldrows]) - mu)
         }
         else {
             mae = abs(y[foldrows] - mu)
         }
         mse = mae^2
         excluded_foldrows = excluded_rows[foldrows]
         mae = mae[!excluded_foldrows]
         mse = mse[!excluded_foldrows]
         if (ks_test) {
             z = (y[foldrows] - mu_not_log)/sigma_not_log
             ks = tryCatch(stats::ks.test(z, "pnorm"), warning = function(w) {
                 warning(w)
                 dup = duplicated(z)
                 if (sum(dup) > 0) {
                     dup = which(dup)[1]
                     dup = which(z == z[dup])
                     dup = which(foldrows)[dup]
                     ks = suppressWarnings(stats::ks.test(z, "pnorm"))
                     outlist = list(warning = w, duplicates = dup, statistic = ks$statistic, 
                       p.value = ks$p.value)
                     class(outlist) = "error_ks"
                     return(outlist)
                 }
             })
         }
         if (isFunc) {
             rows = foldrows & !excluded_rows
             f_user = tryCatch(fun(fit, y[rows], object$X_mu[rows, ], object$X_sigma[rows, 
                 ]), error = function(e) {
                 outlist = list(error = e)
                 class(outlist) = "error_func"
                 return(outlist)
             })
         }
         outlist = list(mae = mean(mae), mse = mean(mse), mse_sqrt = sqrt(mean(mse)))
         if (ks_test) {
             outlist$ks = ks
         }
         if (isFunc) {
             outlist$fun = f_user
         }
         return(outlist)
     })
  3: do.call(c, clusterApply(cl = cl, x = splitList(X, nchunks), fun = lapply, FUN = fun, 
         ...), quote = TRUE)
  4: clusterApply(cl = cl, x = splitList(X, nchunks), fun = lapply, FUN = fun, ...)
  5: staticClusterApply(cl, fun, length(x), argfun)
  6: checkForRemoteErrors(val)
  7: stop(count, " nodes produced errors; first error: ", firstmsg, domain = NA)
  
  ══ testthat results  ═══════════════════════════════════════════════════════════
  OK: 148 SKIPPED: 5 FAILED: 4
  1. Error: print.cvlmvar works correctly (@test_cross_validations.R#158) 
  2. Failure: cv.lmvar works with class Matrix (@test_cross_validations.R#175) 
  3. Error: cv.lmvar error handling works (@test_cross_validations.R#275) 
  4. Error: cv.lmvar works with model matrix with one column (@test_cross_validations.R#307) 
  
  Error: testthat unit tests failed
  In addition: Warning messages:
  1: In UseMethod("chol") : closing unused connection 5 (<-localhost:11448)
  2: In UseMethod("chol") : closing unused connection 4 (<-localhost:11448)
  3: closing unused connection 6 (<-localhost:11448) 
  4: closing unused connection 5 (<-localhost:11448) 
  5: closing unused connection 4 (<-localhost:11448) 
  6: closing unused connection 3 (<-localhost:11448) 
  Execution halted