use pointindex

This commit is contained in:
Joachim Schöberl 2019-09-04 13:46:40 +02:00
parent 93116f253c
commit 3e6f4b9472

View File

@ -42,11 +42,9 @@ namespace ngcore
[](TFlat & self, TIND i) -> T& [](TFlat & self, TIND i) -> T&
{ {
static constexpr int base = IndexBASE<TIND>(); static constexpr int base = IndexBASE<TIND>();
static_assert(base==0 || base==1, "IndexBASE not in [0,1]"); if (i < base || i >= self.Size()+base)
if (i < 0 || i >= self.Size())
throw py::index_error(); throw py::index_error();
if(base==1) i++; return self[i];
return self[i]; // Access from Python is always 0-based
}, },
py::return_value_policy::reference) py::return_value_policy::reference)
.def("__iter__", [] ( TFlat & self) { .def("__iter__", [] ( TFlat & self) {