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