So here is my problem. I am writing a software with mathematica, that uses an external package as a resource. They are some libraries for numerical integration, the CUBA libraries. http://www.feynarts.de/cuba/ The name of the function I use is Suave. It is essentially a better version of NIntegrate. Like NIntegrate, it has several options. Now, as I use it many times in my code, and always using the same options, I found this way to save the options and then plug them in at each use
$CUBAOptions={PrecisionGoal->$cubaintegralprecision,AccuracyGoal->$cubaintegralaccuracy,MinPoints->$MinPointsCUBA,MaxPoints->$MaxPointsCUBA,Verbose->$SOutput,PseudoRandom->$PseudoRandomC,Compiled->$CompiledC};
$SSpecOptions={NNew->$NIncreaseS/10,Flatness->$FlatnessS};
$SOptions=Join[$CUBAOptions,$SSpecOptions];
Install["Suave"];
MyFunctionS[m_]:=Suave[Integrand[r,Eu,s,t,m],{r,ereg,rmax},{Eu,1,EumaxE[muf[r],B[r],meff[r]]},{s,sminE[Eu,m,B[r],meff[r]],smaxE[Eu,m,B[r],meff[r]]},{t,tminE[s,m,meff[r],muf[r]],tmaxE},##&@@$SOptions];
where the last line is present many times in the code, this is just one of the repeated used, all similar.
Now with this approach, I get some shadowing warning messages when I load the code with definitions (not when I use it, just on load). It says that the option names (like Flatness, NNew and so on...are present both in global and in CUBA context.
I hoped I could solve the problem by just inserting e "remove" before "Install", but after I do that, I get another problem
Message[Suave::optx, Removed["Flatness"], Suave]
Any suggestion on how to deal with this issue? I would like to still be able to define the options in a central, compact way, but without incurring in shadowing problems.
EDIT: I forgot to clarify a couple of differences between CUBA/Suave and NIntegrate.
This code works with NIntegrate:
MyOptions={"AccuracyGoal"->1};
NIntegrate[1,{x,0,1}, Evaluate@MyOptions]
However the following 3 examples do NOT work with Suave
MyOptions={"AccuracyGoal"->1};
Suave[1,{x,0,1}, Evaluate@MyOptions]
Suave[1,{x,0,1},{AccuracyGoal->1}]
Suave[1,{x,0,1},"AccuracyGoal"->1]
The first two just return as output the input function, unevaluated. The third one says unknown option
##&
, there isSequence
. Also you can usually just pass in the options as a list and it works just fine. $\endgroup$"NNew"
, they will work just the same. But if symbols like$cubaintegralprecision
are defined in the package you need to use their fully-qualified name - including context. $\endgroup$"Suave"
package is older and does not use theOptionsPattern
andOptionValue
functions that make everything work like I describe above. If you evaluateInstall["Suave"];
first before reading in the definitions of$SOptions
, then everything works correctly is that right? $\endgroup$Install
(which effectively "loads" the package) before using any CUBA-provided option names. It appears to me that this is a case of trying to use a package before having loaded it, except that the concept of "loading" is a bit unusual in this case (done throughInstall
). $\endgroup$