I have a function with Options, and I want to pass the Options to a subfunctions, including both Options with default values and Options with input values. For example, I want to pass the Options of func1
to func2
:
Options[func1] = {Option1 -> DefaultValue11, Option2 -> DefaultValue12, Option3 -> DefaultValue13};
Options[func2] = {Option1 -> DefaultValue21, Option2 -> DefaultValue22};
func1[x_, opts: OptionsPattern[]] := func2[x, FilterRules[opts, Options[func2]]]
func2[x_, opts: OptionsPattern[]] := {OptionValue[Option1], OptionValue[Option2]}
In this case, if I run func1[1, Option1 -> InputValue1]
, then opts
will only match the input option Option1 -> InputValue1
, hence give:
In[1]:=func1[1, Option1 -> InputValue1]
Out[1]={InputValue1, DefaultValue22}
However, I would like something like opts: OptionsPattern[]
, but matching {Option1 -> InputValue1, Option2 -> DefaultValue12, Option3 -> DefaultValue13}
, thus giving:
In[2]:=func1[1, Option1 -> InputValue1]
Out[2]={InputValue1, DefaultValue12}
How can I do that? Thanks in advance.