Skip to content

Commit

Permalink
Merge branch 'feature/circleci' into feature/circleci
Browse files Browse the repository at this point in the history
  • Loading branch information
ivigns authored Mar 3, 2019
2 parents 50fd599 + 225956c commit ee4768f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 48 deletions.
7 changes: 7 additions & 0 deletions pysdsl/types/int_vectors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DEF_INC_VECTOR(4, uint8_t)
DEF_INC_VECTOR(8, uint8_t)
DEF_INC_VECTOR(16, uint16_t)
DEF_INC_VECTOR(24, uint32_t)
DEF_INC_VECTOR(32, uint32_t)
DEF_INC_VECTOR(48, uint64_t)
DEF_INC_VECTOR(64, uint64_t)
97 changes: 49 additions & 48 deletions pysdsl/types/intvector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,21 @@ inline auto add_int_class(py::module& m, py::dict& dict, KEY_T key,
return cls;
}

template <typename VectorT>
auto add_int_vector(py::module& m, py::dict& int_vectors_dict) {
size_t width = VectorT::fixed_int_width;
std::string name = "Int" + std::to_string(width) + "Vector";
return add_int_class<VectorT, typename VectorT::value_type>(
m, int_vectors_dict, width, name.c_str())
.def(py::init(
[width](size_t size, typename VectorT::value_type default_value) {
return VectorT(size, default_value, width); }),
py::arg("size") = 0, py::arg("default_value") = 0);
}

inline auto add_int_vectors(py::module& m)
{
py::dict int_vectors_dict;

m.attr("int_vector") = int_vectors_dict;

return std::make_tuple(
add_int_class<sdsl::int_vector<0>>(
template<>
auto add_int_vector<sdsl::int_vector<0>>(py::module& m, py::dict& int_vectors_dict) {
return add_int_class<sdsl::int_vector<0>>(
m, int_vectors_dict, "dynamic", "IntVector", doc_int_vector)
.def(
py::init([](size_t size,
Expand All @@ -198,59 +204,54 @@ inline auto add_int_vectors(py::module& m)
[](sdsl::int_vector<0> &self) {
sdsl::util::bit_compress(self); },
doc_bit_compress,
py::call_guard<py::gil_scoped_release>()),
py::call_guard<py::gil_scoped_release>());
}

add_int_class<sdsl::int_vector<1>, bool>(
template <>
auto add_int_vector<sdsl::int_vector<1>>(py::module& m, py::dict& int_vectors_dict) {
return add_int_class<sdsl::int_vector<1>, bool>(
m, int_vectors_dict, 1ul , "BitVector")
.def(py::init(
[](size_t size, bool default_value) {
return sdsl::int_vector<1>(size, default_value, 1); }),
py::arg("size") = 0, py::arg("default_value") = false)
.def("flip", &sdsl::int_vector<1>::flip,
"Flip all bits of bit_vector",
py::call_guard<py::gil_scoped_release>()),
py::call_guard<py::gil_scoped_release>());
}

add_int_class<sdsl::int_vector<4>, uint16_t>(
m, int_vectors_dict, 4, "Int4Vector")
.def(py::init(
[](size_t size, uint8_t default_value) {
return sdsl::int_vector<4>(size, default_value, 4); }),
py::arg("size") = 0, py::arg("default_value") = 0),

add_int_class<sdsl::int_vector<8>, uint16_t>(
m, int_vectors_dict, 8, "Int8Vector")
.def(py::init(
[](size_t size, uint8_t default_value) {
return sdsl::int_vector<8>(size, default_value, 8); }),
py::arg("size") = 0, py::arg("default_value") = 0),
template <typename... VectorT>
auto make_int_vectors(py::module& m, py::dict& int_vectors_dict) {
return std::make_tuple(add_int_vector<VectorT>(m, int_vectors_dict)...);
}

add_int_class<sdsl::int_vector<16>, uint16_t>(
m, int_vectors_dict, 16, "Int16Vector")
.def(py::init(
[](size_t size, uint16_t default_value) {
return sdsl::int_vector<16>(size, default_value, 16); }),
py::arg("size") = 0, py::arg("default_value") = 0),

add_int_class<sdsl::int_vector<24>, uint32_t>(
m, int_vectors_dict, 24, "Int24Vector")
.def(py::init(
[](size_t size, uint32_t default_value) {
return sdsl::int_vector<24>(size, default_value, 24); }),
py::arg("size") = 0, py::arg("default_value") = 0),
inline auto add_int_vectors(py::module& m)
{
py::dict int_vectors_dict;

add_int_class<sdsl::int_vector<32>, uint32_t>(
m, int_vectors_dict, 32, "Int32Vector")
.def(py::init(
[](size_t size, uint32_t default_value) {
return sdsl::int_vector<32>(size, default_value, 32); }),
py::arg("size") = 0, py::arg("default_value") = 0),
m.attr("int_vector") = int_vectors_dict;

add_int_class<sdsl::int_vector<64>, uint64_t>(
m, int_vectors_dict, 64, "Int64Vector")
.def(py::init(
[](size_t size, uint64_t default_value) {
return sdsl::int_vector<64>(size, default_value, 64); }),
py::arg("size") = 0, py::arg("default_value") = 0)
);
return make_int_vectors<sdsl::int_vector<0>,
sdsl::int_vector<1>,
sdsl::int_vector<4>,
sdsl::int_vector<8>,
sdsl::int_vector<16>,
sdsl::int_vector<24>,
sdsl::int_vector<32>,
sdsl::int_vector<48>,
sdsl::int_vector<64>>(m, int_vectors_dict);

// #define DEF_INC_VECTOR(width, value_type) ,\
// add_int_class<sdsl::int_vector<width>, value_type>( \
// m, int_vectors_dict, width, "Int" #width "Vector") \
// .def(py::init( \
// [](size_t size, value_type default_value) { \
// return sdsl::int_vector<width>(size, default_value, width); }), \
// py::arg("size") = 0, py::arg("default_value") = 0)
// #include "int_vectors.h"
// #undef DEF_INC_VECTOR
// );

}

0 comments on commit ee4768f

Please sign in to comment.