CMS 3D CMS Logo

PyBind11Wrapper.h
Go to the documentation of this file.
1 #ifndef FWCore_PyBind11ParameterSet_PyBind11Wrapper_h
2 #define FWCore_PyBind11ParameterSet_PyBind11Wrapper_h
3 
4 #include <vector>
5 #include <string>
6 #include <pybind11/pybind11.h>
7 #include <pybind11/stl.h>
8 #include <iostream>
9 
10 namespace edm {
11  void pythonToCppException(const std::string& iType, const std::string& error);
12 
13  // utility to translate from an STL vector of strings to
14  // a Python list
15 
16  template <typename T>
17  pybind11::list toPython11List(const std::vector<T>& v) {
18  pybind11::list result = pybind11::cast(v);
19  return result;
20  }
21 
22  // and back. Destroys the input via pop()s - well probably not
23  template <typename T>
24  std::vector<T> toVector(pybind11::list& l) {
25  std::vector<T> result;
26  result.reserve(l.size());
27  for (unsigned i = 0; i < l.size(); ++i) {
28  result.push_back(l[i].cast<T>());
29  }
30  return result;
31  }
32 } // namespace edm
33 
34 #endif
void pythonToCppException(const std::string &iType, const std::string &error)
std::enable_if< std::is_same< data_T, ap_uint< 1 > >::value &&std::is_same< typename CONFIG_T::weight_t, ap_uint< 1 > >::value, ap_int< nnet::ceillog2(CONFIG_T::n_in)+2 > >::type cast(typename CONFIG_T::accum_t x)
Definition: nnet_mult.h:88
std::vector< T > toVector(pybind11::list &l)
pybind11::list toPython11List(const std::vector< T > &v)
HLT enums.