# no error if argument and method don't correspond
"fitAbn() wrapper of 'mle' and 'bayes' works"
"fitAbn() works with DAG as formula statement"
"'centre' should be either TRUE or FALSE"
# workaround to not overconsume threads on CRAN. This is related to an issue reported for lme4
# workaround to not overconsume threads on CRAN. This is related to an issue reported for lme4 (https://github.com/lme4/lme4/issues/627)
# create.graph argument is deprecated and should be ignored.
#BUG: this switches back to internal C code eventhough INLA is enforced...
"fitabn() works with all distributions, grouping and class abnCache"
# remove grouping variable from distribution list
"`data.df` and `object` provided but can only accept one of them"
"`data.dists` and `object` provided but can only accept one of them"

fitAbn() wrapper of 'mle' and 'bayes' works

Error in `eval(code, test_env)`: object 'm.0.bayes.1' not found

fitAbn() works with DAG as formula statement

Expected `fitAbn(...)` to run without any errors.
i Actually got a <packageNotFoundError> with text:
  there is no package called 'INLA'

myres.c.test <- fitAbn(dag=mydag, data.df=mydat, data.dists=mydists, method = "bayes")
expect_equal(unname(unclass(myres.c.test)[["used.INLA"]]), myres.c[[13]]) # historical reasons. Can be updated in the future.

# historical reasons. Can be updated in the future.

invisible(mycache.test <- buildScoreCache(data.df=mydat, data.dists=mydists, method = "bayes", max.parents=1))
test_that("mostProbable() is backward compatible with `ex0.dag.data`", {
colnames(ban) <- rownames(ban) <- names(mydat); #names must be set
ban["b1","b2"] <- 1; # now ban arc from b2 to b1
colnames(retain) <- rownames(retain) <- names(mydat); #names must be set
retain["g1","g2"] <- 1; # always retain arc from g2 to g1
mp.dag <- mostProbable(score.cache=mycache, verbose = FALSE);
# get the corresponding best goodness of fit - network score
m2 <- fitAbn(object = mp.dag,data.df=mydat,data.dists=mydists)$mlik;
test_that("mostProbable() is backward compatible with `ex1.dag.data`", {
mydat <- ex1.dag.data;## this data comes with abn see ?ex1.dag.data
mp.dag <- mostProbable(score.cache=mycache.exemple1, verbose = FALSE);
m1 <- fitAbn(dag=mp.dag,data.df=mydat,data.dists=mydists)$mlik; # this is ok, because mp.dag is provided to 'dag=', eventhough it actually is an object.
}, regexp = "'data.df' is missing but must be provided") # if mp.dag is provided as dag, even it is an object, we need data.df and data.dists.
test_that("mostProbable() is backward compatible with `ex3.dag.data`", {
## example 3 - models with random effects
## this data comes with abn see ?ex3.dag.data
## each node uses a random effect adjustment
mp.dag <- mostProbable(score.cache=mycache.mixed, verbose = FALSE);
m <- fitAbn(object = mp.dag,data.df=mydat,data.dists=mydists,group.var="group",cor.vars=c("b1","b2","b3","b4"))$mlik;
m <- fitAbn(object = mp.dag,group.var="group",cor.vars=c("b1","b2","b3","b4"))$mlik;
test_that("mostProbable() simple, historic numeric test", {
invisible(mycache.test <- buildScoreCache(data.df=mydat, data.dists=mydists, method = "bayes", max.parents=max.par))