-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[py] added Python binding of CtcStatic
- Loading branch information
1 parent
0680b21
commit 5c64d19
Showing
4 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python | ||
|
||
import unittest | ||
from pyibex import Interval, IntervalVector | ||
from codac import * | ||
|
||
class TestCtcStatic(unittest.TestCase): | ||
|
||
def test_ctcstatic_1(self): | ||
|
||
dt = 0.1 | ||
tdomain = Interval(0.,10.) | ||
|
||
ctc_f = CtcFunction(Function("t", "x[2]", "(x[0]-t;x[1]-t)")) | ||
ctc_static = CtcStatic(ctc_f, True) | ||
|
||
x = TubeVector(tdomain, dt, 2) | ||
|
||
cn = ContractorNetwork() | ||
cn.add(ctc_static, [x]) | ||
cn.contract() | ||
|
||
expected = Tube(tdomain, dt, TFunction("t")) | ||
self.assertEqual(x[0], expected) | ||
self.assertEqual(x[1], expected) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* \file | ||
* CtcStatic Python binding | ||
* ---------------------------------------------------------------------------- | ||
* \date 2021 | ||
* \author Simon Rohou | ||
* \copyright Copyright 2021 Codac Team | ||
* \license This program is distributed under the terms of | ||
* the GNU Lesser General Public License (LGPL). | ||
*/ | ||
|
||
#include <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
#include <pybind11/operators.h> | ||
#include <pybind11/functional.h> | ||
#include "pyIbex_type_caster.h" | ||
|
||
#include "codac_py_DynCtc.h" | ||
#include "codac_CtcStatic.h" | ||
// Generated file from Doxygen XML (doxygen2docstring.py): | ||
#include "codac_py_CtcStatic_docs.h" | ||
|
||
using namespace std; | ||
using namespace ibex; | ||
using namespace codac; | ||
namespace py = pybind11; | ||
using namespace pybind11::literals; | ||
|
||
|
||
void export_CtcStatic(py::module& m, py::class_<DynCtc, pyDynCtc>& dyn_ctc) | ||
{ | ||
py::class_<CtcStatic> ctc_picard(m, "CtcStatic", dyn_ctc, CTCSTATIC_MAIN); | ||
ctc_picard | ||
|
||
.def(py::init<Ctc&,bool>(), | ||
CTCSTATIC_CTCSTATIC_CTC_BOOL, | ||
"ibex_ctc"_a, "temporal_ctc"_a=false) | ||
|
||
.def("contract", (void (CtcStatic::*)(Tube&))&CtcStatic::contract, | ||
CTCSTATIC_VOID_CONTRACT_TUBE, | ||
"x"_a.noconvert()) | ||
|
||
.def("contract", (void (CtcStatic::*)(TubeVector&) )&CtcStatic::contract, | ||
CTCSTATIC_VOID_CONTRACT_TUBEVECTOR, | ||
"x"_a.noconvert()) | ||
; | ||
} |