Utopia 2
Framework for studying models of complex & adaptive systems.
|
Writing data, reading configuration files, and reporting data to the Python frontend. More...
Modules | |
DataManager | |
High-level interface for data writing. | |
Graph Utilities | |
Provides functions which wrap common tasks for writing out data from graphs. | |
Chunking Utilities | |
Provides algorithms for automatically optimize the chunksize in which data is written to the hard disk when writing compressed or extendable hdf5 files. | |
HDF5 | |
Low-level interface for using HDF5 with modern C++ and STL. | |
Monitor | |
Interface for monitoring custom quantities for a simulation via standard out. | |
Config Utilities | |
Allows reading configuration entries from YAML files. | |
Filesystem | |
Namespaces | |
namespace | Utopia::DataIO::GraphLoad |
namespace | Utopia::DataIO::GraphUtilsHelper |
Functions | |
template<class Exc > | |
YAML::Exception | Utopia::DataIO::improve_yaml_exception (const Exc &e, const Config &node, std::string prefix={}) |
Improves yaml-cpp exceptions occurring for a given node. | |
std::string | Utopia::DataIO::to_string (const Config &node) |
Given a config node, returns a string representation of it. | |
template<typename CVecT , DimType dim = 0> | |
CVecT | Utopia::DataIO::get_as_arma_vec (const std::string &key, const DataIO::Config &node) |
Retrieve a config entry as Armadillo column vector using get_. | |
template<class T , class Keys = std::list<std::string>> | |
Config | Utopia::_internal::__recursive_setitem (Config d, Keys &&key_sequence, const T &val) |
Helper function for recursive_setitem. | |
Config | Utopia::_internal::recursive_getitem (const Config &d, const std::vector< std::string > &key_sequence) |
Recursively retrieve an element from the configuration tree. | |
Config | Utopia::_internal::recursive_getitem (const Config &d, const std::string &key_sequence, const std::string &delims=".") |
Overload for recursive_getitem, accepting a string-like key sequence. | |
template<class T > | |
void | Utopia::_internal::recursive_setitem (Config &d, std::list< std::string > key_sequence, const T val) |
Recursively sets an element in a configuration tree. | |
template<class T > | |
void | Utopia::_internal::recursive_setitem (Config &d, const std::string &key_sequence, const T val, const std::string &delims=".") |
Overload for recursive_setitem that splits a string into a key sequence. | |
Writing data, reading configuration files, and reporting data to the Python frontend.
Helper function for recursive_setitem.
Expects an (already deep-copied) node that is then recursively iterated through along the key sequence. For the last key in the sequence, the value is being set. Empty path segments in the key sequence are skipped.
std::invalid_argument | upon trailing empty path segments in the key sequence. |
CVecT Utopia::DataIO::get_as_arma_vec | ( | const std::string & | key, |
const DataIO::Config & | node | ||
) |
Retrieve a config entry as Armadillo column vector using get_.
CVecT | The Armadillo vector type to return |
dim | The dimensionality of the vector (only needed for) |
YAML::Exception Utopia::DataIO::improve_yaml_exception | ( | const Exc & | e, |
const Config & | node, | ||
std::string | prefix = {} |
||
) |
Improves yaml-cpp exceptions occurring for a given node.
Config Utopia::_internal::recursive_getitem | ( | const Config & | d, |
const std::string & | key_sequence, | ||
const std::string & | delims = "." |
||
) |
Overload for recursive_getitem, accepting a string-like key sequence.
Returns the configuration node at the path specified by the key sequence.
d | The configuration tree to retrieve the element from |
key_sequence | A string denoting the path within the tree to get the item from. The path is split into segments using Utopia::split |
delims | Delimiters (plural!) that split the string into a key sequence. |
delims
sequence acts as separator. See Utopia::split for more information on behaviour of the delims
argument. Config Utopia::_internal::recursive_getitem | ( | const Config & | d, |
const std::vector< std::string > & | key_sequence | ||
) |
Recursively retrieve an element from the configuration tree.
Actually uses a loop internally to avoid recursion... ¯_(ツ)_/¯
recursive_setitem
functionality should be used – assigning a value to the returned Config object will not lead to a change in the tree provided via the d
argument.d | The configuration tree to retrieve the element from |
key_sequence | A key sequence denoting the path within the tree to get the item from. |
void Utopia::_internal::recursive_setitem | ( | Config & | d, |
const std::string & | key_sequence, | ||
const T | val, | ||
const std::string & | delims = "." |
||
) |
Overload for recursive_setitem that splits a string into a key sequence.
d | The configuration tree to set the entry in. |
key_sequence | A string to split into a sequence of keys to walk along inside the tree. |
val | The value to assign to the element of the tree specified by the key sequence. |
delims | Delimiters to generate a key sequence from the given string key_sequence . |
delims
sequence acts as separator. See Utopia::split for more information on behaviour of the delims
argument. void Utopia::_internal::recursive_setitem | ( | Config & | d, |
std::list< std::string > | key_sequence, | ||
const T | val | ||
) |
Recursively sets an element in a configuration tree.
This also creates all intermediate segments that may be missing.
As the YAML::Node::operator[] does not return references, this internally has to create a (deep) copy of the given node d
. After recursing through it and setting the value, it will finally assign to the d
reference.
d | The configuration tree to set the entry in. |
key_sequence | A container with a sequence of keys to walk along inside the tree. |
val | The value to assign to the element of the tree specified by the key sequence. |