MUCollective / multiverse

R package for creating explorable multiverse analysis
https://mucollective.github.io/multiverse/
GNU General Public License v3.0
62 stars 5 forks source link

Allow a branch to be used multiple times as long as the options are the same #8

Closed mjskay closed 4 years ago

mjskay commented 5 years ago
M$some_var = ~ branch(parameter,
  "option1" ~ some expr 1,
  "option2" ~ some expr 2
)

M$some_other_var = ~ branch(parameter,
  "option2" ~ some expr 3,
  "option1" ~ some expr 4
)

because the option names are the same (and should work even if they are out of order).

M$some_var = ~ branch(parameter,
  "option1" ~ some expr,
  "option2" ~ some expr
)

M$some_other_var = ~ branch(parameter,
  "option1" ~ some expr
)

Because option2 is not accounted for in the second branch. Add a test for this.

One solution is to just take the union of all the option names when merging, and then have the error happen during execution of universes that are impossible

abhsarma commented 4 years ago

Right now, what this does is:

inside(M, {some_var = ~ branch(parameter,
  "option1" ~ some expr 1,
  "option2" ~ some expr 2
)
})

inside(M, {some_other_var = ~ branch(parameter,
  "option2" ~ some expr 3,
  "option1" ~ some expr 4
)})

creates 4 unique universes, with parameters being parameter and parameter.1 with 2 options for each. I am not sure if that's the desired behavior. Also affects #14.

mjskay commented 4 years ago

Ah yeah, that's not the desired behavior. It should only create two universes?

abhsarma commented 4 years ago

I'll take a look, but might need a more customised implementation than the one we have right now