BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
PyCallback Class Reference
Collaboration diagram for PyCallback:

Public Types

enum  CallbackType { SCALAR , RESIDUAL }
 

Public Member Functions

 PyCallback (CallbackType callback_type=SCALAR)
 
virtual ~PyCallback ()
 
CallbackType callback_type () const
 
virtual double call_scalar (Fit::Parameters pars)
 
virtual std::vector< double > call_residuals (Fit::Parameters pars)
 

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 27 of file PyCallback.h.

27 { 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:45
CallbackType callback_type() const
Definition: PyCallback.cpp:19

◆ ~PyCallback()

PyCallback::~PyCallback ( )
virtualdefault

Member Function Documentation

◆ 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 Fit::Minimizer::minimize().

◆ call_scalar()

double PyCallback::call_scalar ( Fit::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 Fit::Minimizer::minimize().

◆ call_residuals()

std::vector< double > PyCallback::call_residuals ( Fit::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 Fit::Minimizer::minimize().

Member Data Documentation

◆ m_callback_type

CallbackType PyCallback::m_callback_type
private

Definition at line 45 of file PyCallback.h.

Referenced by callback_type().


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