File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ if(NOT NUMPY_WITH_BROKEN_UFUNC_SUPPORT)
3939endif ()
4040add_lib_unit_test(std_vector)
4141add_lib_unit_test(std_array)
42+ add_lib_unit_test(std_pair)
4243add_lib_unit_test(user_struct)
4344
4445function (config_bind_optional tagname opttype)
@@ -115,6 +116,10 @@ add_python_unit_test("py-std-array" "unittest/python/test_std_array.py"
115116 "python;unittest" )
116117set_tests_properties ("py-std-array" PROPERTIES DEPENDS ${PYWRAP} )
117118
119+ add_python_unit_test("py-std-pair" "unittest/python/test_std_pair.py"
120+ "python;unittest" )
121+ set_tests_properties ("py-std-pair" PROPERTIES DEPENDS ${PYWRAP} )
122+
118123add_python_unit_test("py-user-struct" "unittest/python/test_user_struct.py"
119124 "python;unittest" )
120125set_tests_properties ("py-user-struct" PROPERTIES DEPENDS ${PYWRAP} )
Original file line number Diff line number Diff line change 1+ from std_pair import std_pair_to_tuple
2+
3+ t = (1 , 2.0 )
4+ assert std_pair_to_tuple (t ) == t
Original file line number Diff line number Diff line change 1+ // / @file
2+ // / @copyright Copyright 2023 CNRS INRIA
3+
4+ #include < eigenpy/eigenpy.hpp>
5+ #include < eigenpy/std-pair.hpp>
6+ #include < iostream>
7+
8+ namespace bp = boost::python;
9+
10+ template <typename T1, typename T2>
11+ bp::tuple std_pair_to_tuple (const std::pair<T1, T2>& pair) {
12+ return bp::make_tuple (pair.first , pair.second );
13+ }
14+
15+ BOOST_PYTHON_MODULE (std_pair) {
16+ using namespace eigenpy ;
17+
18+ enableEigenPy ();
19+
20+ typedef std::pair<int , double > PairType;
21+ StdPairConverter<PairType>::registration ();
22+
23+ bp::def (" std_pair_to_tuple" , std_pair_to_tuple<int , double >);
24+ }
You can’t perform that action at this time.
0 commit comments