Nektar++
Functions
NekPyConvertors.hpp File Reference
#include <boost/python.hpp>
#include <map>
#include <vector>

Go to the source code of this file.

Functions

template<typename KeyT , typename ValT >
py::dict MapToPyDict (const std::map< KeyT, ValT > &input)
 Converts a std::map to a Python dict. More...
 
template<typename T >
py::list VectorToPyList (const std::vector< T > &input)
 Converts a std::vector to a Python list. More...
 

Function Documentation

◆ MapToPyDict()

template<typename KeyT , typename ValT >
py::dict MapToPyDict ( const std::map< KeyT, ValT > &  input)
inline

Converts a std::map to a Python dict.

Parameters
inputa std::map
Returns
a Python dict with the same entries as the input map

Definition at line 51 of file NekPyConvertors.hpp.

52{
53 py::dict ret;
54 for (auto &entry : input)
55 {
56 ret[entry.first] = entry.second;
57 }
58 return ret;
59}

Referenced by SessionReader_GetParameters().

◆ VectorToPyList()

template<typename T >
py::list VectorToPyList ( const std::vector< T > &  input)
inline

Converts a std::vector to a Python list.

Parameters
inputa std::vector
Returns
a Python list with the same elements as the input vector

Definition at line 68 of file NekPyConvertors.hpp.

69{
70 py::list ret;
71 for (auto &entry : input)
72 {
73 ret.append(entry);
74 }
75 return ret;
76}

Referenced by SessionReader_GetVariables().