Skip to content

Commit 2845917

Browse files
committed
Update ensemble.R
1 parent ad55535 commit 2845917

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

R/ensemble.R

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,17 @@ tsensemble.tsissm.selection_simulate <- function(object, weights = NULL, start =
124124

125125
.ensemble_decompose <- function(object, start = 1)
126126
{
127-
out <- future_lapply(1:length(object$models), function(i){
128-
tsdecompose(object$models[[i]], start = start)
129-
}, future.seed = TRUE, future.packages = "tsissm")
130-
out <- eval(out)
127+
n_cores <- nbrOfWorkers()
128+
if (n_cores <= 1) {
129+
out <- lapply(1:length(object$models), function(i){
130+
tsdecompose(object$models[[i]], start = start)
131+
})
132+
} else {
133+
out <- future_lapply(1:length(object$models), function(i){
134+
tsdecompose(object$models[[i]], start = start)
135+
}, future.seed = TRUE, future.packages = "tsissm")
136+
out <- eval(out)
137+
}
131138
return(out)
132139
}
133140

0 commit comments

Comments
 (0)