hydroPSO
hydroPSO copied to clipboard
hydroPSO: Passing arguments to model.FUN with fn="hydromodInR"
According to to the documentation, there is no way to pass arguments to model.FUN
when fn
is set to "hydromodInR"
:
https://github.com/hzambran/hydroPSO/blob/2f8f8f132b81b8d1e900ebb884d955fce40196ab/man/hydroPSO.Rd#L34-L36
https://github.com/hzambran/hydroPSO/blob/2f8f8f132b81b8d1e900ebb884d955fce40196ab/man/hydroPSO.Rd#L68-L70
The code actually passes the ellipsis:
https://github.com/hzambran/hydroPSO/blob/2f8f8f132b81b8d1e900ebb884d955fce40196ab/R/PSO_v2013.R#L2650-L2659
From how I understand the intention behind "hydromodInR"
(arg checking etc) I believe model.FUN.args
should be used here instead.
If you like I can make a PR if you let me know how you want this resolved.
In the TUWmodel-vignette, your hydroPSO
call uses fn="hydromodInR"
and passes arguments through model.FUN.args
(l320 ff), which does not actually work.
The example still runs in this case because you defined fn
with object references as default arguments (l265 ff), which are assigned in the script before the hydroPSO
call and then get plucked from a parent env
every time fn
is evaluated.
I think this should be changed as well – assigning variables as default args is confusing at best and might lead to unexpected results (for example when improperly parallelized).