Skip to content

Commit

Permalink
memcheck?
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Clark committed Nov 15, 2024
1 parent 17bec3d commit 81908f0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
31 changes: 18 additions & 13 deletions R/forecast.mvgam.R
Original file line number Diff line number Diff line change
Expand Up @@ -861,21 +861,26 @@ forecast_draws = function(object,
envir = environment())

# Grab internal functions to export to each worker
funs_list <- c('extract_general_trend_pars',
'linkfun',
'forecast_trend',
'extract_series_trend_pars',
'mvgam_predict',
'prep_varma_params',
'sim_varma',
'validate_equaldims',
'varma_recursC',
'log_sum_exp')
attr(funs_list, 'envir') <- as.environment(asNamespace("mvgam"))
attr(funs_list, 'mode') <- 'function'
# funs_list <- c('extract_general_trend_pars',
# 'linkfun',
# 'forecast_trend',
# 'extract_series_trend_pars',
# 'mvgam_predict',
# 'prep_varma_params',
# 'sim_varma',
# 'validate_equaldims',
# 'varma_recursC',
# 'log_sum_exp')
# attr(funs_list, 'envir') <- as.environment(asNamespace("mvgam"))
# attr(funs_list, 'mode') <- 'function'
#
# parallel::clusterExport(cl = cl,
# funs_list,
# envir = as.environment(asNamespace("mvgam")))

parallel::clusterExport(cl = cl,
funs_list,
unclass(lsf.str(envir = asNamespace("mvgam"),
all = TRUE)),
envir = as.environment(asNamespace("mvgam")))

fc_preds <- parallel::parLapply(cl = cl, seq_len(dim(betas)[1]), function(i){
Expand Down
2 changes: 1 addition & 1 deletion R/sim_mvgam.R
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ sim_mvgam = function(T = 100,
(obs_trends[,x] * trend_rel)

} else {
yseason <- as.vector(scale(stl(ts(rnorm(T, glob_season, sd = 2),
yseason <- as.vector(scale(stats::stl(ts(rnorm(T, glob_season, sd = 2),
frequency = freq), 'periodic')$time.series[,1]))
dynamics <- (yseason * (1 - trend_rel)) +
(obs_trends[,x] * trend_rel)
Expand Down
Binary file removed src/RcppExports.gcda
Binary file not shown.
Binary file removed src/trend_funs.gcda
Binary file not shown.
8 changes: 4 additions & 4 deletions tests/testthat/test-RW.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@ test_that("VARMAs are set up correctly", {
run_model = FALSE)
expect_true(inherits(var, 'mvgam_prefit'))

var <- mvgam(y ~ s(series, bs = 're') +
var <- SW(mvgam(y ~ s(series, bs = 're') +
gp(time, c = 5/4, k = 20) - 1,
trend_model = VAR(),
data = gaus_data$data_train,
family = gaussian(),
run_model = FALSE)
run_model = FALSE))
expect_true(inherits(var, 'mvgam_prefit'))

varma <- mvgam(y ~ s(series, bs = 're') +
varma <- SW(mvgam(y ~ s(series, bs = 're') +
s(season, bs = 'cc') - 1,
trend_model = 'VARMA',
data = gaus_data$data_train,
family = gaussian(),
run_model = FALSE)
run_model = FALSE))

expect_true(any(grepl('// unconstrained ma inverse partial autocorrelations',
varma$model_file, fixed = TRUE)))
Expand Down

0 comments on commit 81908f0

Please sign in to comment.