GCC Code Coverage Report


Directory: ./
File: include/tsid/bindings/python/constraint/constraint-bound.hpp
Date: 2024-08-26 20:29:39
Exec Total Coverage
Lines: 24 30 80.0%
Branches: 35 70 50.0%

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
2/4
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
7 cl.def(bp::init<std::string>((bp::arg("name")),
37 "Default constructor with name."))
38
3/6
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
7 .def(bp::init<std::string, unsigned int>(
39
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 (bp::arg("name"), bp::arg("size")),
40 "Default constructor with name and size."))
41
4/8
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
14 .def(bp::init<std::string, Eigen::VectorXd, Eigen::VectorXd>(
42
3/6
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
21 (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
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 .add_property("cols", &ConstraintBound::cols)
47
4/8
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
14 .def("resize", &ConstraintBound::resize, (bp::arg("r"), bp::arg("c")),
48 "Resize constraint size.")
49
50
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 .add_property("isEquality", &ConstraintBound::isEquality)
51
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 .add_property("isInequality", &ConstraintBound::isInequality)
52
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 .add_property("isBound", &ConstraintBound::isBound)
53
54
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 .add_property("vector", &ConstraintPythonVisitor::vector)
55
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 .add_property("lowerBound", &ConstraintPythonVisitor::lowerBound)
56
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 .add_property("upperBound", &ConstraintPythonVisitor::upperBound)
57
58
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 .def("setVector",
59 (bool(ConstraintBound::*)(
60 const Eigen::Ref<const Eigen::VectorXd>)) &
61 ConstraintBound::setVector,
62 bp::args("vector"), "Set Vector")
63
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 .def("setLowerBound",
64 (bool(ConstraintBound::*)(
65 const Eigen::Ref<const Eigen::VectorXd>)) &
66 ConstraintBound::setLowerBound,
67 bp::args("lb"), "Set LowerBound")
68
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 .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
1/2
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7 std::string doc = "Constraint Bound info.";
86
1/2
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
7 bp::class_<ConstraintBound>(class_name.c_str(), doc.c_str(), bp::no_init)
87
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 .def(ConstraintPythonVisitor<ConstraintBound>());
88 7 }
89 };
90 } // namespace python
91 } // namespace tsid
92
93 #endif // ifndef __tsid_python_constriant_bound_hpp__
94