diff --git a/dune/python/istl/bvector.hh b/dune/python/istl/bvector.hh index 2524a1810cb07f4032bf83e5b46e2ba10ce961c2..682ca4b1bb5cb34b94b4e371fbb5523da7613d3d 100644 --- a/dune/python/istl/bvector.hh +++ b/dune/python/istl/bvector.hh @@ -158,24 +158,11 @@ namespace Dune cls.def( "__len__", [] ( const BlockVector &self ) { return self.N(); } ); - cls.def( pybind11::self += pybind11::self ); - -// silence a warning (false positive) emitted by clang -// https://bugs.llvm.org/show_bug.cgi?id=43124 -#ifdef __clang__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wself-assign-overloaded" -#endif - - cls.def( pybind11::self -= pybind11::self ); - -#ifdef __clang__ -#pragma GCC diagnostic pop -#endif - detail::registerOneTensorInterface( cls ); detail::registerISTLIterators( cls ); + cls.def( "__iadd__", [] ( BlockVector &self, const BlockVector& x ) -> BlockVector & { self += x; return self; } ); + cls.def( "__isub__", [] ( BlockVector &self, const BlockVector& x ) -> BlockVector & { self -= x; return self; } ); cls.def( "__imul__", [] ( BlockVector &self, field_type x ) -> BlockVector & { self *= x; return self; } ); cls.def( "__idiv__", [] ( BlockVector &self, field_type x ) -> BlockVector & { self /= x; return self; } ); cls.def( "__itruediv__", [] ( BlockVector &self, field_type x ) -> BlockVector & { self /= x; return self; } ); diff --git a/dune/python/test/bcrsmatrix.py b/dune/python/test/bcrsmatrix.py index 5d813057184d30240d56566b222ed6237699d006..9dc93fac28b68db866362dfc3daca8dded478c87 100644 --- a/dune/python/test/bcrsmatrix.py +++ b/dune/python/test/bcrsmatrix.py @@ -121,3 +121,12 @@ str_x = str_x +")" if str_x != s: raise Exception(str(x) + " = str(x) != " + s) + +q=x.copy() +q+=q +for i in range(0,5): + assert(q[i][0] == 2*x[i][0]) + +q-=x +for i in range(0,5): + assert(q[i][0] == x[i][0]) \ No newline at end of file