<div dir="ltr">I just pushed my commit [1] on my branch,<div><br></div><div>A few notes:</div><div>- you need to have python3.5m in /usr/include to compile (I used Python3).</div><div>- I created a src/ directory in dune-common/ which contains the wrapper and the unit test in a subdirectory test/</div><div>- to run the test, run `./dune-commun/bin/dunecontrol --only=dune-commun all` in the root directory (which contains all DUNE modules) and then `python3 -m unittest -v test_fvector.py" in dune-common/src/test`</div><div>This should return</div><div><br></div><div><ol class="" style="color:rgb(172,172,172);margin:0px;padding:0px 0px 0px 55px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace,serif;font-size:12px;line-height:24px;background:rgb(247,247,247)"><li class="" style="background:rgb(255,255,255)"><div class="" style="padding:0px 8px;vertical-align:top;color:rgb(51,51,51);border-left-width:1px;border-left-style:solid;border-left-color:rgb(221,221,221);background-image:initial;background-repeat:initial">test_constructorByCopy (test_fvector.TestWrapperDoubleFieldVector) ... ok</div></li><li class="" style="background:rgb(255,255,255)"><div class="" style="padding:0px 8px;vertical-align:top;color:rgb(51,51,51);border-left-width:1px;border-left-style:solid;border-left-color:rgb(221,221,221);background-image:initial;background-repeat:initial">test_constructorByValue (test_fvector.TestWrapperDoubleFieldVector) ... ok</div></li><li class="" style="background:rgb(255,255,255)"><div class="" style="padding:0px 8px;vertical-align:top;color:rgb(51,51,51);border-left-width:1px;border-left-style:solid;border-left-color:rgb(221,221,221);background:rgb(248,248,248)">test_getItem (test_fvector.TestWrapperDoubleFieldVector) ... ok</div></li><li class="" style="background:rgb(255,255,255)"><div class="" style="padding:0px 8px;vertical-align:top;color:rgb(51,51,51);border-left-width:1px;border-left-style:solid;border-left-color:rgb(221,221,221);background-image:initial;background-repeat:initial">test_len (test_fvector.TestWrapperDoubleFieldVector) ... ok</div></li><li class="" style="background:rgb(255,255,255)"><div class="" style="padding:0px 8px;vertical-align:top;color:rgb(51,51,51);border-left-width:1px;border-left-style:solid;border-left-color:rgb(221,221,221);background-image:initial;background-repeat:initial"> </div></li><li class="" style="background:rgb(255,255,255)"><div class="" style="padding:0px 8px;vertical-align:top;color:rgb(51,51,51);border-left-width:1px;border-left-style:solid;border-left-color:rgb(221,221,221);background-image:initial;background-repeat:initial">----------------------------------------------------------------------</div></li><li class="" style="background:rgb(255,255,255)"><div class="" style="padding:0px 8px;vertical-align:top;color:rgb(51,51,51);border-left-width:1px;border-left-style:solid;border-left-color:rgb(221,221,221);background-image:initial;background-repeat:initial">Ran 4 tests in 0.001s</div></li><li class="" style="background:rgb(255,255,255)"><div class="" style="padding:0px 8px;vertical-align:top;color:rgb(51,51,51);border-left-width:1px;border-left-style:solid;border-left-color:rgb(221,221,221);background-image:initial;background-repeat:initial"> </div></li><li class="" style="background:rgb(255,255,255)"><div class="" style="padding:0px 8px;vertical-align:top;color:rgb(51,51,51);border-left-width:1px;border-left-style:solid;border-left-color:rgb(221,221,221);background-image:initial;background-repeat:initial">OK</div></li></ol><div><br></div><div>- if you want to use the wrapper in the python interpret, just run python3 in dune-common/build-cmake/src/ and then "import libfvector"</div><div><br></div><div>Any comment is more than welcome!</div><div><br></div><div>Best,</div><div>Michaël</div><div><br></div><div>[1] <a href="https://gitlab.dune-project.org/michael.sghaier/dune-common/commit/f675c5a16f06c504e3c3e67c71f0706297193d34">https://gitlab.dune-project.org/michael.sghaier/dune-common/commit/f675c5a16f06c504e3c3e67c71f0706297193d34</a></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-03-16 12:31 GMT-04:00 Michaël Sghaïer <span dir="ltr"><<a href="mailto:sghaier.michael@gmail.com" target="_blank">sghaier.michael@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Oh, I just realized that I forgot the "this" pointer parameter for my function get_item... Shame on me. Whatever, I can now handle a range of dimensions and even several data types!<div>I will now focuse on the unit test (before sending a git patch) and a draft for my proposal.</div><div><br></div><div>Best,</div><div>Michaël</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2016-03-16 3:25 GMT-04:00 Michaël Sghaïer <span dir="ltr"><<a href="mailto:sghaier.michael@gmail.com" target="_blank">sghaier.michael@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I have been working on the junior job related to the Python bindings for two days and I have some questions:</div><div><br></div><div>2016-03-15 14:51 GMT-04:00 Andreas Dedner:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">Note that FieldVector derives from DenseVector and many methods that need to be wrapped are implemented there.</div></blockquote><div><br></div><div>Do we have to wrap the methods of DenseVector too or just the methods of FieldVector?</div><div><br></div><div>Until this junior job, I never used Boost.Python. Though I found it very interesting and funny to play with, it's a little tricky to use. Can you confirm me that we can't wrap the following constructors, due to the fact that templates have to be instanciated at compile time:</div><div><br></div><div><br></div><div>template<class C></div><div>FieldVector (const DenseVector<C> &x, ...)</div><div><br></div><div>and</div><div><br></div><div>template<class K1, int SIZE1></div><div>explicit FieldVector(const FieldVector<K1, SIZE1> & x)</div><div><br></div><div>?</div><div><br></div><div>(same for Base::operator= I guess)</div><div><br></div><div>Last question, the junior job says that the wrapper should work with a range of dimensions. I assume that means it should be easy for a user to add a wrapper for a particular dimension (because templates can't be specialized at runtime, through the Python interpreter, right?).</div><div><br></div><div>I tried to define a template<int SIZE> struct registerFieldVector which defines a static function pointer get_item to wrap operator[] but it doesn't work. I have been debugging for hours now and I don't find a solution.</div><div><br></div><div>For example, </div><div><br></div><div><pre style="color:rgb(0,0,0)">static double& (*get_item) (Dune::FieldVector<double, SIZE>::size_type);
<br></pre><pre style="color:rgb(0,0,0)">...</pre><pre style="color:rgb(0,0,0)">template<>
double& (*RegisterFieldVector<7>::get_item) (Dune::FieldVector<double, 7>::size_type = &Dune::FieldVector<double, 7>::operator[];</pre><pre style="color:rgb(0,0,0)">raises the error: "<span style="font-family:arial,sans-serif">error: cannot declare pointer to ‘double&’ in </span><span style="font-family:arial,sans-serif">static double& (*get_item) (Dune::FieldVector<double, SIZE>::size_type);</span><span style="font-family:arial,sans-serif">"</span></pre><pre style="color:rgb(0,0,0)"><br></pre><pre style="color:rgb(0,0,0)">Could you give me any lead?</pre></div><div>Best,</div></div><div>Michaël</div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>