GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
// |
||
2 |
// Copyright (c) 2018 CNRS |
||
3 |
// |
||
4 |
// This file is part of tsid |
||
5 |
// tsid is free software: you can redistribute it |
||
6 |
// and/or modify it under the terms of the GNU Lesser General Public |
||
7 |
// License as published by the Free Software Foundation, either version |
||
8 |
// 3 of the License, or (at your option) any later version. |
||
9 |
// tsid is distributed in the hope that it will be |
||
10 |
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
||
11 |
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||
12 |
// General Lesser Public License for more details. You should have |
||
13 |
// received a copy of the GNU Lesser General Public License along with |
||
14 |
// tsid If not, see |
||
15 |
// <http://www.gnu.org/licenses/>. |
||
16 |
// |
||
17 |
|||
18 |
#ifndef __tsid_python_constriant_bound_hpp__ |
||
19 |
#define __tsid_python_constriant_bound_hpp__ |
||
20 |
|||
21 |
#include "tsid/bindings/python/fwd.hpp" |
||
22 |
|||
23 |
#include "tsid/math/constraint-bound.hpp" |
||
24 |
|||
25 |
namespace tsid { |
||
26 |
namespace python { |
||
27 |
namespace bp = boost::python; |
||
28 |
|||
29 |
template <typename ConstraintBound> |
||
30 |
struct ConstraintPythonVisitor |
||
31 |
: public boost::python::def_visitor< |
||
32 |
ConstraintPythonVisitor<ConstraintBound> > { |
||
33 |
template <class PyClass> |
||
34 |
|||
35 |
7 |
void visit(PyClass& cl) const { |
|
36 |
✓✗ | 7 |
cl.def(bp::init<std::string>((bp::arg("name")), |
37 |
"Default constructor with name.")) |
||
38 |
✓✗✓✗ |
7 |
.def(bp::init<std::string, unsigned int>( |
39 |
(bp::arg("name"), bp::arg("size")), |
||
40 |
"Default constructor with name and size.")) |
||
41 |
✓✗✓✗ ✓✗✓✗ ✓✗ |
14 |
.def(bp::init<std::string, Eigen::VectorXd, Eigen::VectorXd>( |
42 |
(bp::arg("name"), bp::arg("lb"), bp::arg("ub")), |
||
43 |
"Default constructor with name and constraint.")) |
||
44 |
|||
45 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
14 |
.add_property("rows", &ConstraintBound::rows) |
46 |
14 |
.add_property("cols", &ConstraintBound::cols) |
|
47 |
✓✗ | 7 |
.def("resize", &ConstraintBound::resize, (bp::arg("r"), bp::arg("c")), |
48 |
"Resize constraint size.") |
||
49 |
|||
50 |
✓✗✓✗ ✓✗✓✗ |
14 |
.add_property("isEquality", &ConstraintBound::isEquality) |
51 |
✓✗ | 7 |
.add_property("isInequality", &ConstraintBound::isInequality) |
52 |
✓✗ | 7 |
.add_property("isBound", &ConstraintBound::isBound) |
53 |
|||
54 |
✓✗ | 7 |
.add_property("vector", &ConstraintPythonVisitor::vector) |
55 |
✓✗✓✗ |
7 |
.add_property("lowerBound", &ConstraintPythonVisitor::lowerBound) |
56 |
✓✗ | 7 |
.add_property("upperBound", &ConstraintPythonVisitor::upperBound) |
57 |
|||
58 |
✓✗ | 7 |
.def("setVector", |
59 |
(bool(ConstraintBound::*)( |
||
60 |
const Eigen::Ref<const Eigen::VectorXd>)) & |
||
61 |
ConstraintBound::setVector, |
||
62 |
bp::args("vector"), "Set Vector") |
||
63 |
✓✗✓✗ |
14 |
.def("setLowerBound", |
64 |
(bool(ConstraintBound::*)( |
||
65 |
const Eigen::Ref<const Eigen::VectorXd>)) & |
||
66 |
ConstraintBound::setLowerBound, |
||
67 |
bp::args("lb"), "Set LowerBound") |
||
68 |
✓✗✓✗ ✓✗ |
14 |
.def("setUpperBound", |
69 |
(bool(ConstraintBound::*)( |
||
70 |
const Eigen::Ref<const Eigen::VectorXd>)) & |
||
71 |
ConstraintBound::setUpperBound, |
||
72 |
bp::args("ub"), "Set UpperBound"); |
||
73 |
7 |
} |
|
74 |
static Eigen::VectorXd vector(const ConstraintBound& self) { |
||
75 |
return self.vector(); |
||
76 |
} |
||
77 |
static Eigen::VectorXd lowerBound(const ConstraintBound& self) { |
||
78 |
return self.lowerBound(); |
||
79 |
} |
||
80 |
static Eigen::VectorXd upperBound(const ConstraintBound& self) { |
||
81 |
return self.upperBound(); |
||
82 |
} |
||
83 |
|||
84 |
7 |
static void expose(const std::string& class_name) { |
|
85 |
✓✗ | 7 |
std::string doc = "Constraint Bound info."; |
86 |
✓✗✓✗ |
7 |
bp::class_<ConstraintBound>(class_name.c_str(), doc.c_str(), bp::no_init) |
87 |
.def(ConstraintPythonVisitor<ConstraintBound>()); |
||
88 |
7 |
} |
|
89 |
}; |
||
90 |
} // namespace python |
||
91 |
} // namespace tsid |
||
92 |
|||
93 |
#endif // ifndef __tsid_python_constriant_bound_hpp__ |
Generated by: GCOVR (Version 4.2) |