BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
PyCallback Class Reference

Base class to wrap Python callable and pass it to C++. More...

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)
 Call Python callable and returns its result. More...
 
virtual double call_scalar (mumufit::Parameters pars)
 Call Python callable and returns its result. More...
 
CallbackType callback_type () const
 

Private Attributes

CallbackType m_callback_type
 

Detailed 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.

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)

Definition at line 17 of file PyCallback.cpp.

CallbackType m_callback_type
Definition: PyCallback.h:44
CallbackType callback_type() const
Definition: PyCallback.cpp:19

◆ ~PyCallback()

PyCallback::~PyCallback ( )
virtualdefault

Member Function Documentation

◆ call_residuals()

std::vector< double > PyCallback::call_residuals ( mumufit::Parameters  pars)
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 31 of file PyCallback.cpp.

32 {
33  throw std::runtime_error("PyCallback::call_residuals() -> Error. Not implemented");
34 }

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

◆ call_scalar()

double PyCallback::call_scalar ( mumufit::Parameters  pars)
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 26 of file PyCallback.cpp.

27 {
28  throw std::runtime_error("PyCallback::call_scalar() -> Error. Not implemented");
29 }

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

◆ callback_type()

PyCallback::CallbackType PyCallback::callback_type ( ) const

Definition at line 19 of file PyCallback.cpp.

20 {
21  return m_callback_type;
22 }

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: