BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
PyCallback.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Fit/Kernel/PyCallback.h
6 //! @brief Defines class PyCallback.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_FIT_KERNEL_PYCALLBACK_H
16 #define BORNAGAIN_FIT_KERNEL_PYCALLBACK_H
17 
18 #include "Fit/Param/Parameters.h"
19 #include <vector>
20 
21 //! Base class to wrap Python callable and pass it to C++. Used in swig interface file,
22 //! intended to be overloaded from Python.
23 
24 class PyCallback {
25 public:
27 
29  virtual ~PyCallback();
30 
32 
33  //! Call Python callable and returns its result. Intended to be overloaded in Python.
34  //! @param pars: Fit parameters object (intentionally passed by value).
35  //! @return value of objective function.
36  virtual double call_scalar(mumufit::Parameters pars);
37 
38  //! Call Python callable and returns its result. Intended to be overloaded in Python.
39  //! @param pars: Fit parameters object (intentionally passed by value).
40  //! @return vector of residuals
41  virtual std::vector<double> call_residuals(mumufit::Parameters pars);
42 
43 private:
45 };
46 
47 #endif // BORNAGAIN_FIT_KERNEL_PYCALLBACK_H
Defines class Parameters.
Base class to wrap Python callable and pass it to C++.
Definition: PyCallback.h:24
CallbackType m_callback_type
Definition: PyCallback.h:44
PyCallback(CallbackType callback_type=SCALAR)
Definition: PyCallback.cpp:17
virtual double call_scalar(mumufit::Parameters pars)
Call Python callable and returns its result.
Definition: PyCallback.cpp:26
virtual std::vector< double > call_residuals(mumufit::Parameters pars)
Call Python callable and returns its result.
Definition: PyCallback.cpp:31
virtual ~PyCallback()
CallbackType callback_type() const
Definition: PyCallback.cpp:19
A collection of fit parameters.
Definition: Parameters.h:26