mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
BitArray indexing from the end
This commit is contained in:
parent
8e38334b9a
commit
44d626f727
@ -1 +1 @@
|
||||
Subproject commit c16da993094988141101ac4d96a9b2c92f9ac714
|
||||
Subproject commit e7e2c79f3f520f78ffc39fcb34f7919003102733
|
@ -37,12 +37,14 @@ PYBIND11_MODULE(pyngcore, m) // NOLINT
|
||||
.def("__len__", &BitArray::Size)
|
||||
.def("__getitem__", [] (BitArray & self, int i)
|
||||
{
|
||||
if (i < 0) i+=self.Size();
|
||||
if (i < 0 || i >= self.Size())
|
||||
throw py::index_error();
|
||||
return self.Test(i);
|
||||
}, py::arg("pos"), "Returns bit from given position")
|
||||
.def("__setitem__", [] (BitArray & self, int i, bool b)
|
||||
{
|
||||
if (i < 0) i+=self.Size();
|
||||
if (i < 0 || i >= self.Size())
|
||||
throw py::index_error();
|
||||
if (b) self.SetBit(i); else self.Clear(i);
|
||||
|
Loading…
Reference in New Issue
Block a user