From 3338e40a58d363d4cf85215efb906a77fc11b6ed Mon Sep 17 00:00:00 2001 From: Gennady Pospelov <g.pospelov@fz-juelich.de> Date: Thu, 5 Jul 2018 15:20:32 +0200 Subject: [PATCH] Silent conversion of lmfit parameters to parameters which FitObjective expect --- .../lmfit_basics_new.py | 23 +-- Wrap/swig/extendCore.i | 23 +++ Wrap/swig/libBornAgainCore.i | 2 + Wrap/swig/renameCore.i | 2 + auto/Wrap/libBornAgainCore.py | 39 ++++- auto/Wrap/libBornAgainCore_wrap.cpp | 159 +++++++++--------- 6 files changed, 141 insertions(+), 107 deletions(-) diff --git a/Examples/python/fitting/ex11_ExternalMinimizer/lmfit_basics_new.py b/Examples/python/fitting/ex11_ExternalMinimizer/lmfit_basics_new.py index 2d2aab3a0c6..253c801b42d 100644 --- a/Examples/python/fitting/ex11_ExternalMinimizer/lmfit_basics_new.py +++ b/Examples/python/fitting/ex11_ExternalMinimizer/lmfit_basics_new.py @@ -7,7 +7,6 @@ import bornagain as ba from bornagain import deg, angstrom, nm import lmfit - real_data = None def get_sample(params): @@ -77,26 +76,6 @@ def create_real_data(): return noisy -def residual(params): - simulation = get_simulation(params) - simulation.runSimulation() - result = simulation.result().array().flatten() - exp = real_data.flatten() - res = result-exp - return res - - -def evaluate(params, objective, real_data): - bapars = ba.Parameters() - print(type(params)) - for p in params: - print(type(p), type(params[p])) - bapars.add(p, params[p].value) - - return objective.evaluate_residuals(bapars) - - - def run_fitting(): """ main function to run fitting @@ -112,7 +91,7 @@ def run_fitting(): params.add('radius', value=8*nm) params.add('length', value=8*nm) - result = lmfit.minimize(evaluate, params, args=(fit_objective, real_data)) + result = lmfit.minimize(fit_objective.evaluate_residuals, params) result.params.pretty_print() print(lmfit.fit_report(result)) diff --git a/Wrap/swig/extendCore.i b/Wrap/swig/extendCore.i index eff8be64f49..24e4b7232bf 100644 --- a/Wrap/swig/extendCore.i +++ b/Wrap/swig/extendCore.i @@ -164,6 +164,29 @@ class SimulationBuilderWrapper(PyBuilderCallback): def addSimulationAndData(self, callback, data, weight): self.wrp = SimulationBuilderWrapper(callback) return self.addSimulationAndData_cpp(self.wrp, data, weight) + + def convert_params(self, params): + """ + Converts parameters to what FitObjective::evaluate expects + """ + + if str(params.__module__) == "lmfit.parameter": + bapars = libBornAgainFit.Parameters() + for p in params: + bapars.add(p, params[p].value) + return bapars + elif type(params) is libBornAgainFit.Parameters: + return params + else: + raise ValueError("Unexpected parameter type") + + def evaluate_residuals(self, params): + return self.evaluate_residuals_cpp(self.convert_params(params)) + + def evaluate(self, params): + return self.evaluate_cpp(self.convert_params(params)) + + %} }; diff --git a/Wrap/swig/libBornAgainCore.i b/Wrap/swig/libBornAgainCore.i index 685e9818703..9d993a77b50 100644 --- a/Wrap/swig/libBornAgainCore.i +++ b/Wrap/swig/libBornAgainCore.i @@ -253,6 +253,8 @@ %import(module="libBornAgainFit") "AttLimits.h" %import(module="libBornAgainFit") "Attributes.h" %import(module="libBornAgainFit") "RealLimits.h" +%import(module="libBornAgainFit") "Parameters.h" +%import(module="libBornAgainFit") "Parameter.h" %include "BAVersion.h" %include "BasicVector3D.h" diff --git a/Wrap/swig/renameCore.i b/Wrap/swig/renameCore.i index 92ebc917f3b..5ae8cf516ab 100644 --- a/Wrap/swig/renameCore.i +++ b/Wrap/swig/renameCore.i @@ -3,6 +3,8 @@ %rename(setSampleBuilderCpp) Simulation::setSampleBuilder; %rename(setSampleBuilderCpp) SpecularSimulation::setSampleBuilder; %rename(addSimulationAndData_cpp) FitObjective::addSimulationAndData; +%rename(evaluate_residuals_cpp) FitObjective::evaluate_residuals; +%rename(evaluate_cpp) FitObjective::evaluate; // force swig to use move ctor instead of copy ctor %typemap(out) SlicedParticle %{ diff --git a/auto/Wrap/libBornAgainCore.py b/auto/Wrap/libBornAgainCore.py index 344fbac8afe..cb0ccb91440 100644 --- a/auto/Wrap/libBornAgainCore.py +++ b/auto/Wrap/libBornAgainCore.py @@ -6706,7 +6706,7 @@ class FitParameterSet(_object): def fitParametersNewKernel(self): - """fitParametersNewKernel(FitParameterSet self) -> Fit::Parameters""" + """fitParametersNewKernel(FitParameterSet self) -> Parameters""" return _libBornAgainCore.FitParameterSet_fitParametersNewKernel(self) @@ -7547,7 +7547,7 @@ class PyBuilderCallback(_object): __del__ = lambda self: None def build_simulation(self, arg0): - """build_simulation(PyBuilderCallback self, Fit::Parameters arg0) -> Simulation""" + """build_simulation(PyBuilderCallback self, Parameters arg0) -> Simulation""" return _libBornAgainCore.PyBuilderCallback_build_simulation(self, arg0) def __disown__(self): @@ -7584,14 +7584,14 @@ class FitObjective(_object): return _libBornAgainCore.FitObjective_addSimulationAndData_cpp(self, callback, data, weight) - def evaluate(self, params): - """evaluate(FitObjective self, Fit::Parameters const & params) -> double""" - return _libBornAgainCore.FitObjective_evaluate(self, params) + def evaluate_cpp(self, params): + """evaluate_cpp(FitObjective self, Parameters params) -> double""" + return _libBornAgainCore.FitObjective_evaluate_cpp(self, params) - def evaluate_residuals(self, params): - """evaluate_residuals(FitObjective self, Fit::Parameters const & params) -> vdouble1d_t""" - return _libBornAgainCore.FitObjective_evaluate_residuals(self, params) + def evaluate_residuals_cpp(self, params): + """evaluate_residuals_cpp(FitObjective self, Parameters params) -> vdouble1d_t""" + return _libBornAgainCore.FitObjective_evaluate_residuals_cpp(self, params) def numberOfFitElements(self): @@ -7642,6 +7642,29 @@ class FitObjective(_object): self.wrp = SimulationBuilderWrapper(callback) return self.addSimulationAndData_cpp(self.wrp, data, weight) + def convert_params(self, params): + """ + Converts parameters to what FitObjective::evaluate expects + """ + + if str(params.__module__) == "lmfit.parameter": + bapars = libBornAgainFit.Parameters() + for p in params: + bapars.add(p, params[p].value) + return bapars + elif type(params) is libBornAgainFit.Parameters: + return params + else: + raise ValueError("Unexpected parameter type") + + def evaluate_residuals(self, params): + return self.evaluate_residuals_cpp(self.convert_params(params)) + + def evaluate(self, params): + return self.evaluate_cpp(self.convert_params(params)) + + + FitObjective_swigregister = _libBornAgainCore.FitObjective_swigregister FitObjective_swigregister(FitObjective) diff --git a/auto/Wrap/libBornAgainCore_wrap.cpp b/auto/Wrap/libBornAgainCore_wrap.cpp index 442480ab471..554cf1fded9 100644 --- a/auto/Wrap/libBornAgainCore_wrap.cpp +++ b/auto/Wrap/libBornAgainCore_wrap.cpp @@ -3724,69 +3724,70 @@ namespace Swig { #define SWIGTYPE_p_observer_t swig_types[270] #define SWIGTYPE_p_observerlist_t swig_types[271] #define SWIGTYPE_p_p_PyObject swig_types[272] -#define SWIGTYPE_p_reference swig_types[273] -#define SWIGTYPE_p_short swig_types[274] -#define SWIGTYPE_p_signed_char swig_types[275] -#define SWIGTYPE_p_size_type swig_types[276] -#define SWIGTYPE_p_std__allocatorT_AxisInfo_t swig_types[277] -#define SWIGTYPE_p_std__allocatorT_BasicVector3DT_double_t_t swig_types[278] -#define SWIGTYPE_p_std__allocatorT_BasicVector3DT_std__complexT_double_t_t_t swig_types[279] -#define SWIGTYPE_p_std__allocatorT_IFormFactor_p_t swig_types[280] -#define SWIGTYPE_p_std__allocatorT_INode_const_p_t swig_types[281] -#define SWIGTYPE_p_std__allocatorT_INode_p_t swig_types[282] -#define SWIGTYPE_p_std__allocatorT_ParameterSample_t swig_types[283] -#define SWIGTYPE_p_std__allocatorT_double_t swig_types[284] -#define SWIGTYPE_p_std__allocatorT_int_t swig_types[285] -#define SWIGTYPE_p_std__allocatorT_std__complexT_double_t_t swig_types[286] -#define SWIGTYPE_p_std__allocatorT_std__string_t swig_types[287] -#define SWIGTYPE_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t swig_types[288] -#define SWIGTYPE_p_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t swig_types[289] -#define SWIGTYPE_p_std__allocatorT_unsigned_long_t swig_types[290] -#define SWIGTYPE_p_std__complexT_double_t swig_types[291] -#define SWIGTYPE_p_std__functionT_IMultiLayerBuilder_pfF_t swig_types[292] -#define SWIGTYPE_p_std__functionT_Simulation_pfF_t swig_types[293] -#define SWIGTYPE_p_std__functionT_void_fF_t swig_types[294] -#define SWIGTYPE_p_std__functionT_void_fSimulationAreaIterator_const_RF_t swig_types[295] -#define SWIGTYPE_p_std__invalid_argument swig_types[296] -#define SWIGTYPE_p_std__mapT_std__string_std__string_t__const_iterator swig_types[297] -#define SWIGTYPE_p_std__shared_ptrT_IFitObserver_t swig_types[298] -#define SWIGTYPE_p_std__shared_ptrT_IMultiLayerBuilder_t swig_types[299] -#define SWIGTYPE_p_std__shared_ptrT_IObserver_t swig_types[300] -#define SWIGTYPE_p_std__vectorT_AxesUnitsWrap__AxesUnits_std__allocatorT_AxesUnitsWrap__AxesUnits_t_t swig_types[301] -#define SWIGTYPE_p_std__vectorT_AxisInfo_std__allocatorT_AxisInfo_t_t swig_types[302] -#define SWIGTYPE_p_std__vectorT_BasicVector3DT_double_t_std__allocatorT_BasicVector3DT_double_t_t_t swig_types[303] -#define SWIGTYPE_p_std__vectorT_BasicVector3DT_std__complexT_double_t_t_std__allocatorT_BasicVector3DT_std__complexT_double_t_t_t_t swig_types[304] -#define SWIGTYPE_p_std__vectorT_FitElement_std__allocatorT_FitElement_t_t swig_types[305] -#define SWIGTYPE_p_std__vectorT_FitElement_std__allocatorT_FitElement_t_t__iterator swig_types[306] -#define SWIGTYPE_p_std__vectorT_HomogeneousRegion_std__allocatorT_HomogeneousRegion_t_t swig_types[307] -#define SWIGTYPE_p_std__vectorT_IFitParameter_p_std__allocatorT_IFitParameter_p_t_t__const_iterator swig_types[308] -#define SWIGTYPE_p_std__vectorT_IFitParameter_p_std__allocatorT_IFitParameter_p_t_t__iterator swig_types[309] -#define SWIGTYPE_p_std__vectorT_IFormFactor_p_std__allocatorT_IFormFactor_p_t_t swig_types[310] -#define SWIGTYPE_p_std__vectorT_ILayout_const_p_std__allocatorT_ILayout_const_p_t_t swig_types[311] -#define SWIGTYPE_p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t swig_types[312] -#define SWIGTYPE_p_std__vectorT_INode_p_std__allocatorT_INode_p_t_t swig_types[313] -#define SWIGTYPE_p_std__vectorT_Material_const_p_std__allocatorT_Material_const_p_t_t swig_types[314] -#define SWIGTYPE_p_std__vectorT_ParameterSample_std__allocatorT_ParameterSample_t_t swig_types[315] -#define SWIGTYPE_p_std__vectorT_PolygonalTopology_std__allocatorT_PolygonalTopology_t_t swig_types[316] -#define SWIGTYPE_p_std__vectorT_RealParameter_p_std__allocatorT_RealParameter_p_t_t swig_types[317] -#define SWIGTYPE_p_std__vectorT_SimulationElement_std__allocatorT_SimulationElement_t_t swig_types[318] -#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[319] -#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[320] -#define SWIGTYPE_p_std__vectorT_size_t_std__allocatorT_size_t_t_t swig_types[321] -#define SWIGTYPE_p_std__vectorT_std__complexT_double_t_std__allocatorT_std__complexT_double_t_t_t swig_types[322] -#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[323] -#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[324] -#define SWIGTYPE_p_std__vectorT_std__vectorT_int_std__allocatorT_int_t_t_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t_t swig_types[325] -#define SWIGTYPE_p_std__vectorT_unsigned_int_std__allocatorT_unsigned_int_t_t swig_types[326] -#define SWIGTYPE_p_std__vectorT_unsigned_long_std__allocatorT_unsigned_long_t_t swig_types[327] -#define SWIGTYPE_p_swig__SwigPyIterator swig_types[328] -#define SWIGTYPE_p_unsigned_char swig_types[329] -#define SWIGTYPE_p_unsigned_int swig_types[330] -#define SWIGTYPE_p_unsigned_long_long swig_types[331] -#define SWIGTYPE_p_unsigned_short swig_types[332] -#define SWIGTYPE_p_value_type swig_types[333] -static swig_type_info *swig_types[335]; -static swig_module_info swig_module = {swig_types, 334, 0, 0, 0, 0}; +#define SWIGTYPE_p_parameters_t swig_types[273] +#define SWIGTYPE_p_reference swig_types[274] +#define SWIGTYPE_p_short swig_types[275] +#define SWIGTYPE_p_signed_char swig_types[276] +#define SWIGTYPE_p_size_type swig_types[277] +#define SWIGTYPE_p_std__allocatorT_AxisInfo_t swig_types[278] +#define SWIGTYPE_p_std__allocatorT_BasicVector3DT_double_t_t swig_types[279] +#define SWIGTYPE_p_std__allocatorT_BasicVector3DT_std__complexT_double_t_t_t swig_types[280] +#define SWIGTYPE_p_std__allocatorT_IFormFactor_p_t swig_types[281] +#define SWIGTYPE_p_std__allocatorT_INode_const_p_t swig_types[282] +#define SWIGTYPE_p_std__allocatorT_INode_p_t swig_types[283] +#define SWIGTYPE_p_std__allocatorT_ParameterSample_t swig_types[284] +#define SWIGTYPE_p_std__allocatorT_double_t swig_types[285] +#define SWIGTYPE_p_std__allocatorT_int_t swig_types[286] +#define SWIGTYPE_p_std__allocatorT_std__complexT_double_t_t swig_types[287] +#define SWIGTYPE_p_std__allocatorT_std__string_t swig_types[288] +#define SWIGTYPE_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t swig_types[289] +#define SWIGTYPE_p_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t swig_types[290] +#define SWIGTYPE_p_std__allocatorT_unsigned_long_t swig_types[291] +#define SWIGTYPE_p_std__complexT_double_t swig_types[292] +#define SWIGTYPE_p_std__functionT_IMultiLayerBuilder_pfF_t swig_types[293] +#define SWIGTYPE_p_std__functionT_Simulation_pfF_t swig_types[294] +#define SWIGTYPE_p_std__functionT_void_fF_t swig_types[295] +#define SWIGTYPE_p_std__functionT_void_fSimulationAreaIterator_const_RF_t swig_types[296] +#define SWIGTYPE_p_std__invalid_argument swig_types[297] +#define SWIGTYPE_p_std__mapT_std__string_std__string_t__const_iterator swig_types[298] +#define SWIGTYPE_p_std__shared_ptrT_IFitObserver_t swig_types[299] +#define SWIGTYPE_p_std__shared_ptrT_IMultiLayerBuilder_t swig_types[300] +#define SWIGTYPE_p_std__shared_ptrT_IObserver_t swig_types[301] +#define SWIGTYPE_p_std__vectorT_AxesUnitsWrap__AxesUnits_std__allocatorT_AxesUnitsWrap__AxesUnits_t_t swig_types[302] +#define SWIGTYPE_p_std__vectorT_AxisInfo_std__allocatorT_AxisInfo_t_t swig_types[303] +#define SWIGTYPE_p_std__vectorT_BasicVector3DT_double_t_std__allocatorT_BasicVector3DT_double_t_t_t swig_types[304] +#define SWIGTYPE_p_std__vectorT_BasicVector3DT_std__complexT_double_t_t_std__allocatorT_BasicVector3DT_std__complexT_double_t_t_t_t swig_types[305] +#define SWIGTYPE_p_std__vectorT_FitElement_std__allocatorT_FitElement_t_t swig_types[306] +#define SWIGTYPE_p_std__vectorT_FitElement_std__allocatorT_FitElement_t_t__iterator swig_types[307] +#define SWIGTYPE_p_std__vectorT_HomogeneousRegion_std__allocatorT_HomogeneousRegion_t_t swig_types[308] +#define SWIGTYPE_p_std__vectorT_IFitParameter_p_std__allocatorT_IFitParameter_p_t_t__const_iterator swig_types[309] +#define SWIGTYPE_p_std__vectorT_IFitParameter_p_std__allocatorT_IFitParameter_p_t_t__iterator swig_types[310] +#define SWIGTYPE_p_std__vectorT_IFormFactor_p_std__allocatorT_IFormFactor_p_t_t swig_types[311] +#define SWIGTYPE_p_std__vectorT_ILayout_const_p_std__allocatorT_ILayout_const_p_t_t swig_types[312] +#define SWIGTYPE_p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t swig_types[313] +#define SWIGTYPE_p_std__vectorT_INode_p_std__allocatorT_INode_p_t_t swig_types[314] +#define SWIGTYPE_p_std__vectorT_Material_const_p_std__allocatorT_Material_const_p_t_t swig_types[315] +#define SWIGTYPE_p_std__vectorT_ParameterSample_std__allocatorT_ParameterSample_t_t swig_types[316] +#define SWIGTYPE_p_std__vectorT_PolygonalTopology_std__allocatorT_PolygonalTopology_t_t swig_types[317] +#define SWIGTYPE_p_std__vectorT_RealParameter_p_std__allocatorT_RealParameter_p_t_t swig_types[318] +#define SWIGTYPE_p_std__vectorT_SimulationElement_std__allocatorT_SimulationElement_t_t swig_types[319] +#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[320] +#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[321] +#define SWIGTYPE_p_std__vectorT_size_t_std__allocatorT_size_t_t_t swig_types[322] +#define SWIGTYPE_p_std__vectorT_std__complexT_double_t_std__allocatorT_std__complexT_double_t_t_t swig_types[323] +#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[324] +#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[325] +#define SWIGTYPE_p_std__vectorT_std__vectorT_int_std__allocatorT_int_t_t_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t_t swig_types[326] +#define SWIGTYPE_p_std__vectorT_unsigned_int_std__allocatorT_unsigned_int_t_t swig_types[327] +#define SWIGTYPE_p_std__vectorT_unsigned_long_std__allocatorT_unsigned_long_t_t swig_types[328] +#define SWIGTYPE_p_swig__SwigPyIterator swig_types[329] +#define SWIGTYPE_p_unsigned_char swig_types[330] +#define SWIGTYPE_p_unsigned_int swig_types[331] +#define SWIGTYPE_p_unsigned_long_long swig_types[332] +#define SWIGTYPE_p_unsigned_short swig_types[333] +#define SWIGTYPE_p_value_type swig_types[334] +static swig_type_info *swig_types[336]; +static swig_module_info swig_module = {swig_types, 335, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -50812,7 +50813,7 @@ fail: } -SWIGINTERN PyObject *_wrap_FitObjective_evaluate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_FitObjective_evaluate_cpp(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; FitObjective *arg1 = (FitObjective *) 0 ; Fit::Parameters *arg2 = 0 ; @@ -50824,18 +50825,18 @@ SWIGINTERN PyObject *_wrap_FitObjective_evaluate(PyObject *SWIGUNUSEDPARM(self), PyObject * obj1 = 0 ; double result; - if (!PyArg_ParseTuple(args,(char *)"OO:FitObjective_evaluate",&obj0,&obj1)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OO:FitObjective_evaluate_cpp",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_FitObjective, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FitObjective_evaluate" "', argument " "1"" of type '" "FitObjective *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FitObjective_evaluate_cpp" "', argument " "1"" of type '" "FitObjective *""'"); } arg1 = reinterpret_cast< FitObjective * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Fit__Parameters, 0 | 0); if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "FitObjective_evaluate" "', argument " "2"" of type '" "Fit::Parameters const &""'"); + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "FitObjective_evaluate_cpp" "', argument " "2"" of type '" "Fit::Parameters const &""'"); } if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FitObjective_evaluate" "', argument " "2"" of type '" "Fit::Parameters const &""'"); + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FitObjective_evaluate_cpp" "', argument " "2"" of type '" "Fit::Parameters const &""'"); } arg2 = reinterpret_cast< Fit::Parameters * >(argp2); result = (double)(arg1)->evaluate((Fit::Parameters const &)*arg2); @@ -50846,7 +50847,7 @@ fail: } -SWIGINTERN PyObject *_wrap_FitObjective_evaluate_residuals(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_FitObjective_evaluate_residuals_cpp(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; FitObjective *arg1 = (FitObjective *) 0 ; Fit::Parameters *arg2 = 0 ; @@ -50858,18 +50859,18 @@ SWIGINTERN PyObject *_wrap_FitObjective_evaluate_residuals(PyObject *SWIGUNUSEDP PyObject * obj1 = 0 ; std::vector< double,std::allocator< double > > result; - if (!PyArg_ParseTuple(args,(char *)"OO:FitObjective_evaluate_residuals",&obj0,&obj1)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OO:FitObjective_evaluate_residuals_cpp",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_FitObjective, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FitObjective_evaluate_residuals" "', argument " "1"" of type '" "FitObjective *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FitObjective_evaluate_residuals_cpp" "', argument " "1"" of type '" "FitObjective *""'"); } arg1 = reinterpret_cast< FitObjective * >(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Fit__Parameters, 0 | 0); if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "FitObjective_evaluate_residuals" "', argument " "2"" of type '" "Fit::Parameters const &""'"); + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "FitObjective_evaluate_residuals_cpp" "', argument " "2"" of type '" "Fit::Parameters const &""'"); } if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FitObjective_evaluate_residuals" "', argument " "2"" of type '" "Fit::Parameters const &""'"); + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FitObjective_evaluate_residuals_cpp" "', argument " "2"" of type '" "Fit::Parameters const &""'"); } arg2 = reinterpret_cast< Fit::Parameters * >(argp2); result = (arg1)->evaluate_residuals((Fit::Parameters const &)*arg2); @@ -124108,7 +124109,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"FitParameterSet_setFixed", _wrap_FitParameterSet_setFixed, METH_VARARGS, (char *)"FitParameterSet_setFixed(FitParameterSet self, vector_string_t pars, bool is_fixed)"}, { (char *)"FitParameterSet_correlationMatrix", _wrap_FitParameterSet_correlationMatrix, METH_VARARGS, (char *)"FitParameterSet_correlationMatrix(FitParameterSet self) -> vdouble2d_t"}, { (char *)"FitParameterSet_setCorrelationMatrix", _wrap_FitParameterSet_setCorrelationMatrix, METH_VARARGS, (char *)"FitParameterSet_setCorrelationMatrix(FitParameterSet self, vdouble2d_t matrix)"}, - { (char *)"FitParameterSet_fitParametersNewKernel", _wrap_FitParameterSet_fitParametersNewKernel, METH_VARARGS, (char *)"FitParameterSet_fitParametersNewKernel(FitParameterSet self) -> Fit::Parameters"}, + { (char *)"FitParameterSet_fitParametersNewKernel", _wrap_FitParameterSet_fitParametersNewKernel, METH_VARARGS, (char *)"FitParameterSet_fitParametersNewKernel(FitParameterSet self) -> Parameters"}, { (char *)"FitParameterSet___getitem__", _wrap_FitParameterSet___getitem__, METH_VARARGS, (char *)"\n" "__getitem__(std::string name) -> IFitParameter\n" "FitParameterSet___getitem__(FitParameterSet self, size_t index) -> IFitParameter\n" @@ -124631,7 +124632,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"FitSuiteObjects_swigregister", FitSuiteObjects_swigregister, METH_VARARGS, NULL}, { (char *)"new_PyBuilderCallback", _wrap_new_PyBuilderCallback, METH_VARARGS, (char *)"new_PyBuilderCallback(PyObject * arg2) -> PyBuilderCallback"}, { (char *)"delete_PyBuilderCallback", _wrap_delete_PyBuilderCallback, METH_VARARGS, (char *)"delete_PyBuilderCallback(PyBuilderCallback self)"}, - { (char *)"PyBuilderCallback_build_simulation", _wrap_PyBuilderCallback_build_simulation, METH_VARARGS, (char *)"PyBuilderCallback_build_simulation(PyBuilderCallback self, Fit::Parameters arg0) -> Simulation"}, + { (char *)"PyBuilderCallback_build_simulation", _wrap_PyBuilderCallback_build_simulation, METH_VARARGS, (char *)"PyBuilderCallback_build_simulation(PyBuilderCallback self, Parameters arg0) -> Simulation"}, { (char *)"disown_PyBuilderCallback", _wrap_disown_PyBuilderCallback, METH_VARARGS, NULL}, { (char *)"PyBuilderCallback_swigregister", PyBuilderCallback_swigregister, METH_VARARGS, NULL}, { (char *)"new_FitObjective", _wrap_new_FitObjective, METH_VARARGS, (char *)"new_FitObjective() -> FitObjective"}, @@ -124640,8 +124641,8 @@ static PyMethodDef SwigMethods[] = { "addSimulationAndData_cpp(PyBuilderCallback callback, vdouble2d_t data, double weight=1.0)\n" "FitObjective_addSimulationAndData_cpp(FitObjective self, PyBuilderCallback callback, vdouble2d_t data)\n" ""}, - { (char *)"FitObjective_evaluate", _wrap_FitObjective_evaluate, METH_VARARGS, (char *)"FitObjective_evaluate(FitObjective self, Fit::Parameters const & params) -> double"}, - { (char *)"FitObjective_evaluate_residuals", _wrap_FitObjective_evaluate_residuals, METH_VARARGS, (char *)"FitObjective_evaluate_residuals(FitObjective self, Fit::Parameters const & params) -> vdouble1d_t"}, + { (char *)"FitObjective_evaluate_cpp", _wrap_FitObjective_evaluate_cpp, METH_VARARGS, (char *)"FitObjective_evaluate_cpp(FitObjective self, Parameters params) -> double"}, + { (char *)"FitObjective_evaluate_residuals_cpp", _wrap_FitObjective_evaluate_residuals_cpp, METH_VARARGS, (char *)"FitObjective_evaluate_residuals_cpp(FitObjective self, Parameters params) -> vdouble1d_t"}, { (char *)"FitObjective_numberOfFitElements", _wrap_FitObjective_numberOfFitElements, METH_VARARGS, (char *)"FitObjective_numberOfFitElements(FitObjective self) -> size_t"}, { (char *)"FitObjective_experimental_array", _wrap_FitObjective_experimental_array, METH_VARARGS, (char *)"FitObjective_experimental_array(FitObjective self) -> vdouble1d_t"}, { (char *)"FitObjective_simulation_array", _wrap_FitObjective_simulation_array, METH_VARARGS, (char *)"FitObjective_simulation_array(FitObjective self) -> vdouble1d_t"}, @@ -138877,6 +138878,7 @@ static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|in static swig_type_info _swigt__p_observer_t = {"_p_observer_t", "observer_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_observerlist_t = {"_p_observerlist_t", "observerlist_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_p_PyObject = {"_p_p_PyObject", "PyObject **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_parameters_t = {"_p_parameters_t", "parameters_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_reference = {"_p_reference", "reference *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0}; @@ -139213,6 +139215,7 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_observer_t, &_swigt__p_observerlist_t, &_swigt__p_p_PyObject, + &_swigt__p_parameters_t, &_swigt__p_reference, &_swigt__p_short, &_swigt__p_signed_char, @@ -139549,6 +139552,7 @@ static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0} static swig_cast_info _swigc__p_observer_t[] = { {&_swigt__p_observer_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_observerlist_t[] = { {&_swigt__p_observerlist_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_p_PyObject[] = { {&_swigt__p_p_PyObject, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_parameters_t[] = { {&_swigt__p_parameters_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_reference[] = { {&_swigt__p_reference, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}}; @@ -139885,6 +139889,7 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_observer_t, _swigc__p_observerlist_t, _swigc__p_p_PyObject, + _swigc__p_parameters_t, _swigc__p_reference, _swigc__p_short, _swigc__p_signed_char, -- GitLab