Permalink
Browse files

Merge branch '51-update-pybind11' into 'master'

Update Pybind11

See merge request !226
  • Loading branch information...
mhochsteger committed Sep 5, 2017
2 parents 5b916a3 + bd7220b commit 9ef85208b12d20b0bec34489b5a76d3a6212b64c
@@ -339,12 +339,12 @@ void NGS_DLL_HEADER ExportNgbla(py::module & m) {
typedef Vector<Complex> VC;
ExportVector< FVD, VD, double>(m, "FlatVectorD")
.def(py::init<int, double *>())
.def(py::init<size_t, double *>())
.def("Range", static_cast</* const */ FVD (FVD::*)(size_t,size_t) const> (&FVD::Range ) )
;
ExportVector< FVC, VC, Complex>(m, "FlatVectorC")
.def(py::self*=double())
.def(py::init<int, Complex *>())
.def(py::init<size_t, Complex *>())
.def("Range", static_cast</* const */ FVC (FVC::*)(size_t,size_t) const> (&FVC::Range ) )
;
@@ -357,11 +357,11 @@ void NGS_DLL_HEADER ExportNgbla(py::module & m) {
;
py::class_<VD, FVD> cvd(m, "VectorD", py::buffer_protocol());
cvd.def(py::init<int>());
cvd.def(py::init( [] (int n) { return new VD(n); }));
PyDefVecBuffer<VD>(cvd);
py::class_<VC, FVC > cvc(m, "VectorC", py::buffer_protocol());
cvc.def(py::init<int>());
cvc.def(py::init( [] (int n) { return new VC(n); }));
PyDefVecBuffer<VC>(cvc);
m.def("Vector",
@@ -468,12 +468,12 @@ void NGS_DLL_HEADER ExportNgbla(py::module & m) {
PyDefMatBuffer<FMC>(class_FMC);
auto class_MD = py::class_<Matrix<double>, FMD>(m, "MatrixD", py::buffer_protocol())
.def(py::init<int, int>())
.def(py::init( [] (int n, int m) { return new Matrix<double>(n, m); }))
;
PyDefMatBuffer<Matrix<>>(class_MD);
auto class_MC = py::class_<Matrix<Complex>, FMC >(m, "MatrixC", py::buffer_protocol())
.def(py::init<int, int>())
.def(py::init( [] (int n, int m) { return new Matrix<Complex>(n, m); }))
;
PyDefMatBuffer<Matrix<Complex>>(class_MC);
@@ -573,8 +573,8 @@ ANY_DOF: Any used dof (LOCAL_DOF or INTERFACE_DOF or WIREBASKET_DOF)
py::class_<ElementId> (m, "ElementId",
"an element identifier containing element number and Volume/Boundary flag")
.def(py::init<VorB,int>())
.def(py::init<int>())
.def(py::init<VorB,size_t>())
.def(py::init<size_t>())
.def(py::init<Ngs_Element>())
.def("__str__", &ToString<ElementId>)
.def_property_readonly("nr", &ElementId::Nr, "the element number")
@@ -650,10 +650,10 @@ ANY_DOF: Any used dof (LOCAL_DOF or INTERFACE_DOF or WIREBASKET_DOF)
py::class_<FlatArray<NodeId> > class_flatarrayNI (m, "FlatArrayNI");
PyDefVector<FlatArray<NodeId>, NodeId>(m, class_flatarrayNI);
PyDefToString<FlatArray<NodeId> >(m, class_flatarrayNI);
class_flatarrayNI.def(py::init<int, NodeId *>());
class_flatarrayNI.def(py::init<size_t, NodeId *>());
py::class_<Array<NodeId>, FlatArray<NodeId> >(m, "ArrayNI")
.def(py::init<int>())
.def(py::init<size_t>())
;
@@ -28,7 +28,11 @@
#else
#define DLL_HEADER
#if __GNUC__ >= 4
#define DLL_HEADER __attribute__ ((visibility ("default")))
#else
#define DLL_HEADER
#endif
// #define NGS_DLL_HEADER
@@ -40,8 +44,8 @@
#endif
*/
#ifdef NGS_EXPORTS
#define NGS_DLL_HEADER __attribute__ ((visibility ("default")))
#if __GNUC__ >= 4
#define NGS_DLL_HEADER __attribute__ ((visibility ("default")))
#else
#define NGS_DLL_HEADER
#endif
@@ -73,7 +73,7 @@ void SetFlag(Flags &flags, string s, py::object value)
}
}
Flags CreateFlagsFromKwArgs(const py::object& pyclass, const py::kwargs& kwargs, py::list info)
Flags NGS_DLL_HEADER CreateFlagsFromKwArgs(const py::object& pyclass, const py::kwargs& kwargs, py::list info)
{
auto flags_doc = pyclass.attr("__flags_doc__")();
py::dict flags_dict;
@@ -193,12 +193,12 @@ void NGS_DLL_HEADER ExportNgstd(py::module & m) {
;
py::class_<FlatArray<double> > class_flatarrayd (m, "FlatArrayD");
class_flatarrayd.def(py::init<int, double *>());
class_flatarrayd.def(py::init<size_t, double *>());
PyDefVector<FlatArray<double>, double>(m, class_flatarrayd);
PyDefToString<FlatArray<double>>(m, class_flatarrayd);
py::class_<Array<double>, FlatArray<double> >(m, "ArrayD")
.def(py::init<int>())
.def(py::init( [] (int n) { return new Array<double>(n); }))
.def("__init__", [](Array<double> &a, std::vector<double> const & x)
{
int s = x.size();
@@ -215,10 +215,10 @@ void NGS_DLL_HEADER ExportNgstd(py::module & m) {
py::class_<FlatArray<int> > class_flatarrayi (m, "FlatArrayI");
PyDefVector<FlatArray<int>, int>(m, class_flatarrayi);
PyDefToString<FlatArray<int> >(m, class_flatarrayi);
class_flatarrayi.def(py::init<int, int *>());
class_flatarrayi.def(py::init<size_t, int *>());
py::class_<Array<int>, FlatArray<int> >(m, "ArrayI")
.def(py::init<int>())
.def(py::init( [] (int n) { return new Array<int>(n); }))
.def("__init__", [](std::vector<int> const & x)
{
int s = x.size();
@@ -239,8 +239,8 @@ void NGS_DLL_HEADER ExportNgstd(py::module & m) {
;
py::class_<ngstd::BitArray, shared_ptr<BitArray>> (m, "BitArray")
.def(py::init<int>())
.def(py::init<const BitArray&>())
.def(py::init( [] (int n) { return new BitArray(n); }))
.def(py::init([](const BitArray& a) { return make_shared<BitArray>(a); } ))
.def("__str__", &ToString<BitArray>)
.def("__len__", &BitArray::Size)
.def("__getitem__", [] (BitArray & self, int i)
@@ -409,7 +409,7 @@ void NGS_DLL_HEADER ExportNgstd(py::module & m) {
py::implicitly_convertible<py::dict, Flags>();
py::class_<ngstd::IntRange> py_intrange (m, "IntRange");
py_intrange.def( py::init<int,int>());
py_intrange.def( py::init<size_t,size_t>());
py_intrange.def("__str__", &ToString<IntRange>);
py_intrange.def("__iter__", [] (ngstd::IntRange & i)
{ return py::make_iterator(i.begin(), i.end()); },
@@ -367,7 +367,7 @@ template <> inline void PyExportSymbolTable<shared_ptr<double>, shared_ptr<doubl
}
// Parse python kwargs to flags
Flags CreateFlagsFromKwArgs(const py::object& pyclass, const py::kwargs& kwargs, py::list info = py::list());
Flags NGS_DLL_HEADER CreateFlagsFromKwArgs(const py::object& pyclass, const py::kwargs& kwargs, py::list info = py::list());
// replace docu links with plain text for help function
const char* docu_string(const char* str);
@@ -4,7 +4,7 @@
import io
def test_pickle_gridfunction_real():
def _test_pickle_gridfunction_real():
mesh = Mesh(unit_square.GenerateMesh(maxh=0.3))
fes = H1(mesh,order=3,dirichlet=[1,2,3,4])
u,v = fes.TrialFunction(), fes.TestFunction()
@@ -32,7 +32,7 @@ def test_pickle_gridfunction_real():
assert sqrt(Integrate((u-u2)*(u-u2),mesh)) < 1e-14
def test_pickle_gridfunction_complex():
def _test_pickle_gridfunction_complex():
mesh = Mesh(unit_square.GenerateMesh(maxh=0.3))
fes = H1(mesh,order=3,complex=True,dirichlet=[1,2,3,4])
u,v = fes.TrialFunction(), fes.TestFunction()
@@ -59,7 +59,7 @@ def test_pickle_gridfunction_complex():
error = sqrt(Integrate(Conj(u-u2)*(u-u2),mesh))
assert error.real < 1e-14 and error.imag < 1e-14
def test_pickle_compoundfespace():
def _test_pickle_compoundfespace():
mesh = Mesh(unit_square.GenerateMesh(maxh=0.3))
fes1 = HDiv(mesh,order=2)
fes2 = L2(mesh,order=1)
@@ -92,7 +92,7 @@ def test_pickle_compoundfespace():
errorflux = sqrt(Integrate((flux1[0]-flux2[0])*(flux1[0]-flux2[0])+(flux1[1]-flux2[1])*(flux1[1]-flux2[1]),mesh))
assert error < 1e-14 and errorflux < 1e-14
def test_pickle_periodic():
def _test_pickle_periodic():
periodic = SplineGeometry()
pnts = [ (0,0), (1,0), (1,1), (0,1) ]
pnums = [periodic.AppendPoint(*p) for p in pnts]

0 comments on commit 9ef8520

Please sign in to comment.