Directory: | ./ |
---|---|
File: | include/tsid/bindings/python/constraint/constraint-inequality.hpp |
Date: | 2024-11-10 01:12:44 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 27 | 35 | 77.1% |
Branches: | 42 | 84 | 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 | #ifndef __tsid_python_constriant_inequality_hpp__ | ||
18 | #define __tsid_python_constriant_inequality_hpp__ | ||
19 | |||
20 | #include "tsid/bindings/python/fwd.hpp" | ||
21 | |||
22 | #include "tsid/math/constraint-inequality.hpp" | ||
23 | |||
24 | namespace tsid { | ||
25 | namespace python { | ||
26 | namespace bp = boost::python; | ||
27 | |||
28 | template <typename ConstraintInequality> | ||
29 | struct ConstraintIneqPythonVisitor | ||
30 | : public boost::python::def_visitor< | ||
31 | ConstraintIneqPythonVisitor<ConstraintInequality> > { | ||
32 | template <class PyClass> | ||
33 | |||
34 | 7 | void visit(PyClass& cl) const { | |
35 |
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")), |
36 | "Default constructor with name.")) | ||
37 |
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, unsigned int, unsigned int>( |
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.
|
21 | (bp::arg("name"), bp::arg("row"), bp::arg("col")), |
39 | "Default constructor with name and size.")) | ||
40 |
5/10✓ 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.
✓ Branch 13 taken 7 times.
✗ Branch 14 not taken.
|
21 | .def(bp::init<std::string, Eigen::MatrixXd, Eigen::VectorXd, |
41 | Eigen::VectorXd>( | ||
42 |
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.
|
28 | (bp::arg("name"), bp::arg("A"), bp::arg("lb"), bp::arg("ub")), |
43 | "Default constructor with name and constraint.")) | ||
44 | |||
45 | 14 | .add_property("rows", &ConstraintInequality::rows) | |
46 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .add_property("cols", &ConstraintInequality::cols) |
47 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("resize", &ConstraintInequality::resize, |
48 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | (bp::arg("r"), bp::arg("c")), "Resize constraint size.") |
49 | |||
50 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .add_property("isEquality", &ConstraintInequality::isEquality) |
51 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .add_property("isInequality", &ConstraintInequality::isInequality) |
52 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .add_property("isBound", &ConstraintInequality::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("matrix", &ConstraintIneqPythonVisitor::matrix) |
55 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .add_property("vector", &ConstraintIneqPythonVisitor::vector) |
56 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .add_property("lowerBound", &ConstraintIneqPythonVisitor::lowerBound) |
57 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .add_property("upperBound", &ConstraintIneqPythonVisitor::upperBound) |
58 | |||
59 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
14 | .def("setMatrix", |
60 | (bool(ConstraintInequality::*)( | ||
61 | const Eigen::Ref<const Eigen::MatrixXd>)) & | ||
62 | ConstraintInequality::setMatrix, | ||
63 | bp::args("matrix"), "Set Matrix") | ||
64 |
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.
|
14 | .def("setVector", |
65 | (bool(ConstraintInequality::*)( | ||
66 | const Eigen::Ref<const Eigen::VectorXd>)) & | ||
67 | ConstraintInequality::setVector, | ||
68 | bp::args("vector"), "Set Vector") | ||
69 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("setLowerBound", |
70 | (bool(ConstraintInequality::*)( | ||
71 | const Eigen::Ref<const Eigen::VectorXd>)) & | ||
72 | ConstraintInequality::setLowerBound, | ||
73 | bp::args("lb"), "Set LowerBound") | ||
74 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | .def("setUpperBound", |
75 | (bool(ConstraintInequality::*)( | ||
76 | const Eigen::Ref<const Eigen::VectorXd>)) & | ||
77 | ConstraintInequality::setUpperBound, | ||
78 | bp::args("ub"), "Set UpperBound"); | ||
79 | 7 | } | |
80 | ✗ | static Eigen::MatrixXd matrix(const ConstraintInequality& self) { | |
81 | ✗ | return self.matrix(); | |
82 | } | ||
83 | ✗ | static Eigen::VectorXd vector(const ConstraintInequality& self) { | |
84 | ✗ | return self.vector(); | |
85 | } | ||
86 | ✗ | static Eigen::VectorXd lowerBound(const ConstraintInequality& self) { | |
87 | ✗ | return self.lowerBound(); | |
88 | } | ||
89 | ✗ | static Eigen::VectorXd upperBound(const ConstraintInequality& self) { | |
90 | ✗ | return self.upperBound(); | |
91 | } | ||
92 | |||
93 | 7 | static void expose(const std::string& class_name) { | |
94 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::string doc = "Constraint Inequality info."; |
95 |
1/2✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
|
7 | bp::class_<ConstraintInequality>(class_name.c_str(), doc.c_str(), |
96 | bp::no_init) | ||
97 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def(ConstraintIneqPythonVisitor<ConstraintInequality>()); |
98 | 7 | } | |
99 | }; | ||
100 | } // namespace python | ||
101 | } // namespace tsid | ||
102 | |||
103 | #endif // ifndef __tsid_python_constriant_inequality_hpp__ | ||
104 |