Functional Features
Python support
Python integration
Overview of important variables and methods for a correct initialization and usage of Python throughout the project. For a smooth integration, Python needs to be initialized before executing Python code by
// Initialization
#ifdef PYTHON_BACKEND
mcmc::execution::initialize_python(PYTHON_SCRIPTS_PATH);
#endif
// Finalization
#ifdef PYTHON_BACKEND
mcmc::execution::finalize_python();
#endif
The CMake variable RUN_WITH_PYTHON_BACKEND needs to be set by -DRUN_WITH_PYTHON_BACKEND=ON (default=ON) when the library is built.
The optional CMake variable PYTHON_SCRIPTS_PATH can be set by -DPYTHON_SCRIPTS_PATH=<path_to_python_modules> when the project is built. The <path_to_python_modules> refers to the directory containing a custom_modules.pyfile and allowing for an integration of custom measure functions and a custom function for loading MCMC simulation data from file.
-
static bool mcmc::util::python_integration::g_is_python_initialized
Variable for checking if Python has been initialized correctly.
-
void mcmc::util::initialize_python(const std::string &python_modules_path, const bool fma_develop = false, const bool executing_from_python = false)
Initialize Python and set important variables.
- Parameters
python_modules_path – Path to a directory containing custom Python code
fma_develop – Indicate whether plots should be written to file or loaded Device::locally
executing_from_python – Variable for indicating whether the code is executed from C++ (false) or executed via pybind from Python (true)
-
void mcmc::util::finalize_python()
Finalize Python.
Integrating external Python modules
-
static std::string mcmc::util::python_integration::g_python_modules_path
Path to the directory containing the
custom_modules.pyfile with custom Python code for computing measures and loading MCMC simulation data.
-
static std::string mcmc::util::python_integration::get_python_modules_path()
Returns the
g_python_modules_path.
-
static void mcmc::util::python_integration::set_python_modules_path(const std::string &python_modules_path)
Sets the
g_python_modules_path.
Utils
Random number generation
Definition of the random generator used throughout the entire project and further useful functions.
-
static std::random_device mcmc::util::random::g_rd
Random device engine, usually based on /dev/random on UNIX-like systems.
-
static std::mt19937 mcmc::util::random::g_gen
Mersenne Twister pseudo-random generator used throughout the entire project.
-
static void mcmc::util::random::set_random_seed(uint32_t seed_val = 0)
Sets the random seed for
mcmc::util::random::g_genused throughout the entire project.- Parameters
seed_val – Random seed
- Returns
None
Linspace intervals
-
template<typename T>
std::vector<T> mcmc::util::linspace(T min, T max, uint num = 1) Returns evenly spaced numbers over a specified interval, where
minandmaxare included.- Parameters
min – Lower bound of the interval
max – Upper bound of the interval
num – Number of numbers in the interval
- Returns
A vector with evenly spaced numbers over the specified interval.