BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
PyCallback Class Reference

Description

Base class to wrap Python callable and pass it to C++. Used in swig interface file, intended to be overloaded from Python.

Definition at line 24 of file PyCallback.h.

Public Types

enum  CallbackType { SCALAR , RESIDUAL }
 

Public Member Functions

 PyCallback (CallbackType callback_type=SCALAR)
 
virtual ~PyCallback ()
 
virtual std::vector< double > call_residuals (mumufit::Parameters pars) const
 Call Python callable and returns its result. Intended to be overloaded in Python. More...
 
virtual double call_scalar (mumufit::Parameters pars) const
 Call Python callable and returns its result. Intended to be overloaded in Python. More...
 
CallbackType callback_type () const
 

Private Attributes

CallbackType m_callback_type
 

Member Enumeration Documentation

◆ CallbackType

Enumerator
SCALAR 
RESIDUAL 

Definition at line 26 of file PyCallback.h.

26 { SCALAR, RESIDUAL };

Constructor & Destructor Documentation

◆ PyCallback()

PyCallback::PyCallback ( PyCallback::CallbackType  callback_type = SCALAR)
explicit

Definition at line 17 of file PyCallback.cpp.

19 {
20 }
CallbackType m_callback_type
Definition: PyCallback.h:44
CallbackType callback_type() const
Definition: PyCallback.cpp:22

◆ ~PyCallback()

PyCallback::~PyCallback ( )
virtualdefault

Member Function Documentation

◆ call_residuals()

std::vector< double > PyCallback::call_residuals ( mumufit::Parameters  pars) const
virtual

Call Python callable and returns its result. Intended to be overloaded in Python.

Parameters
parsFit parameters object (intentionally passed by value).
Returns
vector of residuals

Definition at line 34 of file PyCallback.cpp.

35 {
36  throw std::runtime_error("PyCallback::call_residuals() -> Error. Not implemented");
37 }

Referenced by mumufit::Minimizer::minimize().

◆ call_scalar()

double PyCallback::call_scalar ( mumufit::Parameters  pars) const
virtual

Call Python callable and returns its result. Intended to be overloaded in Python.

Parameters
parsFit parameters object (intentionally passed by value).
Returns
value of objective function.

Definition at line 29 of file PyCallback.cpp.

30 {
31  throw std::runtime_error("PyCallback::call_scalar() -> Error. Not implemented");
32 }

Referenced by mumufit::Minimizer::minimize().

◆ callback_type()

PyCallback::CallbackType PyCallback::callback_type ( ) const

Definition at line 22 of file PyCallback.cpp.

23 {
24  return m_callback_type;
25 }

References m_callback_type.

Referenced by mumufit::Minimizer::minimize().

Member Data Documentation

◆ m_callback_type

CallbackType PyCallback::m_callback_type
private

Definition at line 44 of file PyCallback.h.

Referenced by callback_type().


The documentation for this class was generated from the following files: