diff --git a/Wrap/Swig/libBornAgainSim.i b/Wrap/Swig/libBornAgainSim.i index be08a16266f4e2ab3f9d61c3026c300f7ed11f79..5722cacee597d3b6d462cfc6a2ecacf3ec10e2f4 100644 --- a/Wrap/Swig/libBornAgainSim.i +++ b/Wrap/Swig/libBornAgainSim.i @@ -188,6 +188,27 @@ class ObserverCallbackWrapper(PyObserverCallback): self.callback_container.append(wrp) return self.addSimulationAndData_cpp(wrp, data, *args, **kwargs) + def addFitPair(self, callback, expData, *args): + """ + Sets simulation and experimental data to the fit objective. + Optionally accepts experimental data uncertainties and + user-defined dataset weight. + + Arguments: + + callback -- user-defined function returning fully-defined bornagain.ISimulation object. + The function must use fit parameter dictionary as its input. + + expData -- Datafield containing experimental data. + + weight -- user-defined weight of the dataset. If not specified, defaults to 1.0. + """ + if not hasattr(self, 'callback_container'): + self.callback_container = [] + wrp = SimulationBuilderWrapper(callback) + self.callback_container.append(wrp) # needed ??? + return self.addFitPair_cpp(wrp, data, *args) + def convert_params(self, params): """ Converts parameters to what FitObjective::evaluate expects diff --git a/auto/Wrap/libBornAgainSim.py b/auto/Wrap/libBornAgainSim.py index d43d6838a99bd080a9e7afa1d9849f0d7d0bf789..da1f7fe86b3ad3685b86534f9f429a6f5536f254 100644 --- a/auto/Wrap/libBornAgainSim.py +++ b/auto/Wrap/libBornAgainSim.py @@ -2451,6 +2451,27 @@ class FitObjective(object): self.callback_container.append(wrp) return self.addSimulationAndData_cpp(wrp, data, *args, **kwargs) + def addFitPair(self, callback, expData, *args): + """ + Sets simulation and experimental data to the fit objective. + Optionally accepts experimental data uncertainties and + user-defined dataset weight. + + Arguments: + + callback -- user-defined function returning fully-defined bornagain.ISimulation object. + The function must use fit parameter dictionary as its input. + + expData -- Datafield containing experimental data. + + weight -- user-defined weight of the dataset. If not specified, defaults to 1.0. + """ + if not hasattr(self, 'callback_container'): + self.callback_container = [] + wrp = SimulationBuilderWrapper(callback) + self.callback_container.append(wrp) # needed ??? + return self.addFitPair_cpp(wrp, data, *args) + def convert_params(self, params): """ Converts parameters to what FitObjective::evaluate expects