Skip to content

Commit c07114e

Browse files
committed
docstrings for methods
1 parent 83e74d3 commit c07114e

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

pysdsl/test/test_rmq.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import random
2+
13
from pysdsl import IntVector, Int16Vector
24

35
from pysdsl import rmq_sada, rmq_sct, rmq_sparse_tables
46

5-
import random
67

78

89
def _test_rmq(rmq_class, container_class, target):
@@ -21,7 +22,7 @@ def _test_rmq(rmq_class, container_class, target):
2122

2223
i = rmq(l, r)
2324

24-
assert(cont[i] == target(a[l:r+1]))
25+
assert cont[i] == target(a[l:r+1])
2526

2627

2728
def test_rmq_sada():

pysdsl/types/rmq.hpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@ struct add_rmq_sparse_table_functor {
6161
std::string("Range") + (t_min ? "Min" : "Max") + "QuerySparseTable_for_" + rac_name;
6262

6363
auto cls = py::class_<Table>(m, name.c_str())
64-
.def_property_readonly("size", (size_type(Table::*)(void) const)& Table::size)
6564
.def(py::init([](const t_rac* rac) {return Table(rac);}))
66-
.def("set_vector", &Table::set_vector)
65+
.def("set_vector", &Table::set_vector,
66+
"Sets a vector rmq is processed on.")
6767
.def("__call__",
68-
(size_type (Table::*)(size_type, size_type) const)& Table::operator());
68+
(size_type (Table::*)(size_type, size_type) const)& Table::operator(),
69+
(std::string("Returns an index of the ") + (t_min ? "minimal" : "maximal") +
70+
" value on the segment [l,r].").c_str());
6971

7072
add_sizes(cls);
7173
add_description(cls);
@@ -105,10 +107,11 @@ struct add_rmq_sada_functor {
105107
std::string("Range") + (t_min ? "Min" : "Max") + "QuerySuccintSada";
106108

107109
auto cls = py::class_<RMQClass>(m, name.c_str())
108-
.def_property_readonly("size", (size_type (RMQClass::*)(void) const)& RMQClass::size)
109110
.def(py::init())
110111
.def("__call__",
111-
(size_type (RMQClass::*)(size_type, size_type) const)& RMQClass::operator());
112+
(size_type (RMQClass::*)(size_type, size_type) const)& RMQClass::operator(),
113+
(std::string("Returns an index of the ") + (t_min ? "minimal" : "maximal") +
114+
" value on the segment [l,r].").c_str());;
112115

113116
detail::add_rac_constructor<decltype(cls), t_rac...>(cls);
114117

@@ -146,10 +149,11 @@ struct add_rmq_sct_functor {
146149
std::string("Range") + (t_min ? "Min" : "Max") + "QuerySuccintSct";
147150

148151
auto cls = py::class_<RMQClass>(m, name.c_str())
149-
.def_property_readonly("size", (size_type (RMQClass::*)(void) const)& RMQClass::size)
150152
.def(py::init())
151153
.def("__call__",
152-
(size_type (RMQClass::*)(size_type, size_type) const)& RMQClass::operator());
154+
(size_type (RMQClass::*)(size_type, size_type) const)& RMQClass::operator(),
155+
(std::string("Returns an index of the ") + (t_min ? "minimal" : "maximal") +
156+
" value on the segment [l,r].").c_str());
153157

154158

155159
detail::add_rac_constructor<decltype(cls), t_rac...>(cls);

0 commit comments

Comments
 (0)