Skip to content
Snippets Groups Projects
Commit 30574a43 authored by Carsten Gräser's avatar Carsten Gräser
Browse files

[test] Test python conversion to TupleVector

parent 873a3708
No related branches found
No related tags found
1 merge request!83[test] Test python conversion to TupleVector
Pipeline #31505 passed
......@@ -12,6 +12,8 @@
#include <dune/common/fvector.hh>
#include <dune/common/function.hh>
#include <dune/common/parametertree.hh>
#include <dune/common/tuplevector.hh>
#include <dune/common/indices.hh>
#if HAVE_UG
#include <dune/grid/uggrid.hh>
......@@ -25,6 +27,7 @@
#include <dune/fufem/dunepython.hh>
using namespace Dune::Indices;
int main(int argc, char** argv)
{
......@@ -401,6 +404,7 @@ int main(int argc, char** argv)
auto int_list = module.get("int_list");
auto str_list = module.get("str_list");
auto int_tuple = module.get("int_tuple");
auto mixed_tuple = module.get("mixed_tuple");
// Modify first argument of int_list.
// Similar to calling a Callable you can either hand
......@@ -431,6 +435,15 @@ int main(int argc, char** argv)
std::cout << "python integer tuple converted to vector<int>:" << std::endl;
for(size_t i=0; i<int_vec2.size(); ++i)
std::cout << int_vec2[i] << std::endl;
// Convert python mixed tuple to Dune::TupleVector and print results:
Dune::TupleVector<std::vector<int>,std::string> mixed_tuple_c;
mixed_tuple.toC(mixed_tuple_c);
std::cout << "python mixed tuple (string representation):" << mixed_tuple.str() << std::endl;
std::cout << "python mixed tuple converted to Dune::TupleVector:" << std::endl;
for(size_t i=0; i<mixed_tuple_c[_0].size(); ++i)
std::cout << mixed_tuple_c[_0][i] << std::endl;
std::cout << mixed_tuple_c[_1] << std::endl;
}
......
......@@ -10,6 +10,7 @@ def add(x,y):
int_list=[11,12,13]
str_list=["string1","string2","string3"]
int_tuple=(1,2,3)
mixed_tuple=((1,2),"three")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment