proxsuite-nlp  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear programming on manifolds.
Loading...
Searching...
No Matches
namespace.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <boost/python.hpp>
4
5namespace proxsuite {
6namespace nlp {
7namespace python {
8namespace bp = boost::python;
9
10inline std::string get_scope_name(bp::scope scope) {
11 return std::string(bp::extract<const char *>(scope.attr("__name__")));
12}
13
20inline bp::object get_namespace(const std::string &name) {
21 bp::scope cur_scope; // current scope
22 const std::string complete_name = get_scope_name(cur_scope) + "." + name;
23 bp::object submodule(bp::borrowed(PyImport_AddModule(complete_name.c_str())));
24 cur_scope.attr(name.c_str()) = submodule;
25 return submodule;
26}
27
28} // namespace python
29
30} // namespace nlp
31} // namespace proxsuite
std::string get_scope_name(bp::scope scope)
Definition namespace.hpp:10
bp::object get_namespace(const std::string &name)
Create or retrieve a Python scope (that is, a class or module namespace).
Definition namespace.hpp:20
Main package namespace.
Definition bcl-params.hpp:5