Open mcol opened 5 years ago
Yeah, I think it would be good to change that. I don’t think we should error out if it doesn’t recognize an argument. A warning seems sufficient.
I stumbled upon the same error. I passed the wrong argument to brms (priors
instead of prior
) and received the error:
Start sampling
Error in FUN(X[[i]], ...) :
trying to get slot "mode" from an object (class "try-error") that is not an S4 object
In addition: Warning message:
In parallel::mclapply(1:chains, FUN = callFun, mc.preschedule = FALSE, :
4 function calls resulted in an error
Unfortunately, this error is not informative. Actually, it suggests a more serious problem related to sampling.
Thanks, @JackCaster---This seems like something that brms should catch. Pinging @paul-buerkner in case there isn't already a brms issue to catch errors due to unknown arguments.
Ideally rstan would sort it out, otherwise all interfaces will have to work around it in their code as I had to do here: https://github.com/mcol/hsstan/blob/167cc4e7585b4f3628ac1fdbac0650e75869f2fe/R/misc.R#L387-L408
Usually, interfaces take responsibility or checking their own arguments in order to provide interface-centric error messages and avoid user confusion from embedded messages from calls that should be cleanly encapsulated. For example, rather than waiting for the C++ compiler to fail, the Stan transpolar provides error messages in terms of the Stan code.
Summary:
rstan::sampling
doesn't seem to reject or ignore invalid options passed through the...
argument.Description:
If an invalid option is given, it is not ignored but it causes an ugly failure:
This came up because I have a function that takes a
...
argument that gets passed torstan::sampling
, and I had a typo in one of my arguments (which didn't match and got passed to rstan).Reproducible Steps:
This is enough to see the failure:
Expected Output:
Unrecognized options should be ignored and sampling should proceed correctly. It seems that there's code in the
optimizing
method that checks recognizable names passed through the...
argument, but no such code exists insampling
.RStan Version:
The version of RStan you are running (e.g., from
packageVersion("rstan")
): 2.19.2R Version:
The version of R you are running (e.g., from
R.version.string
): 3.6.1Operating System:
Your operating system (e.g., OS X 10.11.3): Ubuntu 18.04.3 LTS