MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / PyDefROBracketOperator

Function PyDefROBracketOperator

ngstd/python_ngstd.hpp:193–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191// read-only bracket operator
192template< typename T, typename TELEM, typename TCLASS = py::class_<T>>
193void PyDefROBracketOperator( py::module &m, TCLASS &c )
194{
195 auto Get = [](T& self, int i) {
196 if (i < 0) i += self.Size();
197 if( i<self.Size() && i>=0 )
198 return self[i];
199 throw py::index_error();
200 return TELEM();
201 };
202 c.def("__getitem__", Get,py::arg("pos"), "Return value at given position");
203 c.def("Get", Get, py::arg("pos"), "Return value at given position");
204}
205
206// read-write bracket operator
207template< typename T, typename TELEM, typename TCLASS = py::class_<T>>

Callers

nothing calls this directly

Calls 2

argFunction · 0.85
SizeMethod · 0.45

Tested by

no test coverage detected