Pandora-IsoMemo / bmsc

BMSC
https://pandora-isomemo.github.io/bmsc/
GNU General Public License v3.0
0 stars 0 forks source link

Fix Error / Warnings #8

Open jan-abel-inwt opened 2 months ago

jan-abel-inwt commented 2 months ago

see Jenkins

arunge commented 2 months ago

@jan-abel-inwt I startet fixing issues on a feature branch.

Can we already remove all the content of the src folder? Or is there something missing?

arunge commented 2 months ago

@mgross For some longer time the checks were not running in our pipeline because of another Error. We could fix that error, but now the checks are failing. I already updated the Namespace and some documentation on this feature branch. However, there are still some issues. Can you have a look at the following and help to fix it?

A test is failing:

  > test_check("BMSC")
  [ FAIL 1 | WARN 0 | SKIP 0 | PASS 63 ]

  ══ Failed tests ════════════════════════════════════════════════════════════════
  ── Error ('test_bestModel.R:25:3'): test function bestModel ────────────────────
  Error in `.check_ncores(cores)`: 4 simultaneous processes spawned
  Backtrace:
       ▆
    1. └─BMSC::constrSelEst(...) at test_bestModel.R:25:2
    2.   └─BMSC:::selectModel(...)
    3.     └─BMSC:::estimateBayesianModel(...)
    4.       ├─base::suppressWarnings(...)
    5.       │ └─base::withCallingHandlers(...)
    6.       ├─rstan::sampling(...)
    7.       └─rstan::sampling(...)
    8.         └─rstan (local) .local(object, ...)
    9.           └─parallel::mclapply(...)
   10.             └─parallel:::.check_ncores(cores)

  [ FAIL 1 | WARN 0 | SKIP 0 | PASS 63 ]
  Error: Test failures
  Execution halted
* checking for non-standard things in the check directory ... OK
* checking for detritus in the temp directory ... OK
* DONE

Status: 1 ERROR, 2 WARNINGs, 5 NOTEs

Documentation is missing for several slots:

* checking for code/documentation mismatches ... WARNING
S4 class codoc mismatches from documentation object 'ConstrainedLinReg-class':
Slots for class 'ConstrainedLinReg'
  Code: .MISC AIC AICc AUC BIC Bayes_Rsq Loo MallowsCP Rsq RsqAdj WAIC
        ar1 cLevel catVars date designMatrix df formula hasIntercept
        inits mode model_name model_pars nagelkerke par_dims
        scaleCenter scaleScale scaleYCenter scaleYScale sim stan_args
        stanmodel type varNames
  Inherited: model_name model_pars par_dims mode sim inits stan_args
        stanmodel date .MISC
  Docs: cLevel formula hasIntercept scaleCenter scaleScale

A variable cannot be found:

* checking R code for possible problems ... [19s/19s] NOTE
get_avg_model: no visible binding for global variable ‘ar_matrix’
get_avg_model : <anonymous>: no visible binding for global variable
  ‘ar_matrix’
Undefined global functions or variables:
  ar_matrix

Probably some issue with brackets? https://github.com/Pandora-IsoMemo/bmsc/blob/a32a164e14ec493049bd1ca2b900d126a98277c9/R/model_averaging.R#L74-L80

Thanks for helping here! :pray:

mgross commented 2 weeks ago

@arunge: Yes this is a bug. It should be the following instead:

  if(avg_model@ar1){
    ar_matrices <- lapply(1:length(models_input), function(x){
      ar_matrix <- extract(models_input[[x]])$ar
    }) 
    a <- ar_matrices[[1]] * weights[1]
    tmp <- lapply(seq_along(ar_matrices)[-1], function(i){
      a <<- do.call("+", list(a, ar_matrices[[i]]* weights[i]) )
    })
  }
arunge commented 1 week ago

@jan-abel-inwt When you are back, please check the comment here.