From f4c96defd42b130195e6b1add8bb2fbaa5c7f085 Mon Sep 17 00:00:00 2001 From: David Holt Date: Tue, 22 Sep 2020 21:56:09 -0400 Subject: [PATCH] Revert "implement future.apply in forecast.mdl_df" This reverts commit d49e0abf294397b5c7a382d1346118b352fa5d92. It causes issues with evaluation flow, and it is more valuable to parallelise across series rather than models --- R/forecast.R | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/R/forecast.R b/R/forecast.R index 6da48efc..ae10226d 100644 --- a/R/forecast.R +++ b/R/forecast.R @@ -105,38 +105,13 @@ forecast.mdl_df <- function(object, new_data = NULL, h = NULL, object <- bind_new_data(object, new_data) } - object <- tidyr::pivot_longer(object, !!mdls, names_to = ".model", values_to = ".mdl") - # Evaluate forecasts - if(is_attached("package:future")){ - require_package("future.apply") - - object[[".fc"]] <- future.apply::future_mapply( - FUN = forecast, - object[[".mdl"]], - MoreArgs = list( - h = h, - point_forecast = point_forecast, - ..., - key_data = key_data(object) - ), - SIMPLIFY = FALSE, - future.globals = FALSE - ) - } - else{ - object[[".fc"]] <- mapply( - FUN = forecast, - object[[".mdl"]], - MoreArgs = list( - h = h, - point_forecast = point_forecast, - ..., - key_data = key_data(object) - ), - SIMPLIFY = FALSE - ) - } + object <- dplyr::mutate_at(as_tibble(object), vars(!!!mdls), + forecast, object[["new_data"]], + h = h, point_forecast = point_forecast, ..., + key_data = key_data(object)) + + object <- tidyr::pivot_longer(object, !!mdls, names_to = ".model", values_to = ".fc") # Combine and re-construct fable fbl_attr <- attributes(object$.fc[[1]])