Code Monkey home page Code Monkey logo

samplableset's People

Contributors

benmaier avatar gstonge avatar jsleb333 avatar siliz4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

samplableset's Issues

Possible to fail less harshly?

Right now constructing an impossible set throws a segfault that kills the python session.

I'd suggest adding a check to the constructor and raising an error, if possible.

image

Error when trying to compile

Hey Guillaume, thanks for this package, it looks extremely useful! Unfortunately, SamplableSet doesn't compile on my Mac. I'm running macOS 10.14.6 with pybind11 v2.4.2. I'm getting the same errors for v2.2, v2.3, and v.2.5 though.

Maybe you could point me in the right direction?

I'm attaching the error output:

$ sudo -H pip install -e SamplableSet/
Obtaining file:///Users/bfmaier/pythonlib/SamplableSet
Requirement already satisfied: pybind11>=2.2 in /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from SamplableSet==1.0.7) (2.5.0)
Installing collected packages: SamplableSet
  Running setup.py develop for SamplableSet
    Complete output from command /opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -c "import setuptools, tokenize;__file__='/Users/bfmaier/pythonlib/SamplableSet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" develop --no-deps:
    running develop
    running egg_info
    writing SamplableSet.egg-info/PKG-INFO
    writing dependency_links to SamplableSet.egg-info/dependency_links.txt
    writing requirements to SamplableSet.egg-info/requires.txt
    writing top-level names to SamplableSet.egg-info/top_level.txt
    reading manifest file 'SamplableSet.egg-info/SOURCES.txt'
    writing manifest file 'SamplableSet.egg-info/SOURCES.txt'
    running build_ext
    /usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -I/opt/local/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c /tmp/tmp59od5g92.cpp -o tmp/tmp59od5g92.o -std=c++17
    /usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -I/opt/local/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c /tmp/tmp3sgwu8im.cpp -o tmp/tmp3sgwu8im.o -fvisibility=hidden
    building '_SamplableSetCR' extension
    /usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -Isrc/ -I/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c src/bind_SamplableSetCR.cpp -o build/temp.macosx-10.14-x86_64-3.7/src/bind_SamplableSetCR.o -stdlib=libc++ -mmacosx-version-min=10.7 -DVERSION_INFO="1.0.7" -std=c++17 -fvisibility=hidden
    In file included from src/bind_SamplableSetCR.cpp:27:
    src/SamplableSetCR.hpp:119:5: error: field of type 'typename PropensityGroup::iterator' (aka '__wrap_iter<std::__1::pair<int, double> *>') has private constructor
        iterator_(NULL),
        ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:61:68: note: in instantiation of member function 'sset::SamplableSetCR<int>::SamplableSetCR' requested here
    inline Class *construct_or_initialize(Args &&...args) { return new Class(std::forward<Args>(args)...); }
                                                                       ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:174:31: note: in instantiation of function template specialization 'pybind11::detail::initimpl::construct_or_initialize<sset::SamplableSetCR<int>, double, double, unsigned int, 0>' requested here
                v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
                                  ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h:1148:14: note: in instantiation of function template specialization 'pybind11::detail::initimpl::constructor<double, double, unsigned int>::execute<pybind11::class_<sset::SamplableSetCR<int>>, char [252], pybind11::arg, pybind11::arg, pybind11::arg_v, 0>' requested here
            init.execute(*this, extra...);
                 ^
    src/bind_SamplableSetCR.cpp:47:10: note: in instantiation of function template specialization 'pybind11::class_<sset::SamplableSetCR<int>>::def<double, double, unsigned int, char [252], pybind11::arg, pybind11::arg, pybind11::arg_v>' requested here
            .def(py::init<double, double, unsigned int>(), R"pbdoc(
             ^
    src/bind_SamplableSetCR.cpp:138:5: note: in instantiation of function template specialization 'declare_samplable_set<int>' requested here
        declare_samplable_set<int>(m, "Int");
        ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1422:60: note: declared private here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
                                                               ^
    In file included from src/bind_SamplableSetCR.cpp:27:
    src/SamplableSetCR.hpp:144:5: error: field of type 'typename PropensityGroup::iterator' (aka '__wrap_iter<std::__1::pair<int, double> *>') has private constructor
        iterator_(NULL),
        ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:61:68: note: in instantiation of member function 'sset::SamplableSetCR<int>::SamplableSetCR' requested here
    inline Class *construct_or_initialize(Args &&...args) { return new Class(std::forward<Args>(args)...); }
                                                                       ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:174:31: note: in instantiation of function template specialization 'pybind11::detail::initimpl::construct_or_initialize<sset::SamplableSetCR<int>, const sset::SamplableSetCR<int> &, 0>' requested here
                v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
                                  ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h:1148:14: note: in instantiation of function template specialization 'pybind11::detail::initimpl::constructor<const sset::SamplableSetCR<int> &>::execute<pybind11::class_<sset::SamplableSetCR<int>>, char [130], pybind11::arg, 0>' requested here
            init.execute(*this, extra...);
                 ^
    src/bind_SamplableSetCR.cpp:57:10: note: in instantiation of function template specialization 'pybind11::class_<sset::SamplableSetCR<int>>::def<const sset::SamplableSetCR<int> &, char [130], pybind11::arg>' requested here
            .def(py::init<const SamplableSetCR<T>&>(), R"pbdoc(
             ^
    src/bind_SamplableSetCR.cpp:138:5: note: in instantiation of function template specialization 'declare_samplable_set<int>' requested here
        declare_samplable_set<int>(m, "Int");
        ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1422:60: note: declared private here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
                                                               ^
    In file included from src/bind_SamplableSetCR.cpp:27:
    src/SamplableSetCR.hpp:161:5: error: field of type 'typename PropensityGroup::iterator' (aka '__wrap_iter<std::__1::pair<int, double> *>') has private constructor
        iterator_(NULL),
        ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:61:68: note: in instantiation of member function 'sset::SamplableSetCR<int>::SamplableSetCR' requested here
    inline Class *construct_or_initialize(Args &&...args) { return new Class(std::forward<Args>(args)...); }
                                                                       ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:174:31: note: in instantiation of function template specialization 'pybind11::detail::initimpl::construct_or_initialize<sset::SamplableSetCR<int>, const sset::SamplableSetCR<int> &, unsigned int, 0>' requested here
                v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
                                  ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h:1148:14: note: in instantiation of function template specialization 'pybind11::detail::initimpl::constructor<const sset::SamplableSetCR<int> &, unsigned int>::execute<pybind11::class_<sset::SamplableSetCR<int>>, char [170], pybind11::arg, pybind11::arg, 0>' requested here
            init.execute(*this, extra...);
                 ^
    src/bind_SamplableSetCR.cpp:64:10: note: in instantiation of function template specialization 'pybind11::class_<sset::SamplableSetCR<int>>::def<const sset::SamplableSetCR<int> &, unsigned int, char [170], pybind11::arg, pybind11::arg>' requested here
            .def(py::init<const SamplableSetCR<T>&, unsigned int>(), R"pbdoc(
             ^
    src/bind_SamplableSetCR.cpp:138:5: note: in instantiation of function template specialization 'declare_samplable_set<int>' requested here
        declare_samplable_set<int>(m, "Int");
        ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1422:60: note: declared private here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
                                                               ^
    In file included from src/bind_SamplableSetCR.cpp:27:
    src/SamplableSetCR.hpp:119:5: error: field of type 'typename PropensityGroup::iterator' (aka '__wrap_iter<std::__1::pair<std::__1::basic_string<char>, double> *>') has private constructor
        iterator_(NULL),
        ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:61:68: note: in instantiation of member function 'sset::SamplableSetCR<std::__1::basic_string<char> >::SamplableSetCR' requested here
    inline Class *construct_or_initialize(Args &&...args) { return new Class(std::forward<Args>(args)...); }
                                                                       ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:174:31: note: in instantiation of function template specialization 'pybind11::detail::initimpl::construct_or_initialize<sset::SamplableSetCR<std::__1::basic_string<char> >, double, double, unsigned int, 0>' requested here
                v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
                                  ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h:1148:14: note: in instantiation of function template specialization 'pybind11::detail::initimpl::constructor<double, double, unsigned int>::execute<pybind11::class_<sset::SamplableSetCR<std::__1::basic_string<char> >>, char [252], pybind11::arg, pybind11::arg, pybind11::arg_v, 0>' requested here
            init.execute(*this, extra...);
                 ^
    src/bind_SamplableSetCR.cpp:47:10: note: in instantiation of function template specialization 'pybind11::class_<sset::SamplableSetCR<std::__1::basic_string<char> >>::def<double, double, unsigned int, char [252], pybind11::arg, pybind11::arg, pybind11::arg_v>' requested here
            .def(py::init<double, double, unsigned int>(), R"pbdoc(
             ^
    src/bind_SamplableSetCR.cpp:139:5: note: in instantiation of function template specialization 'declare_samplable_set<std::__1::basic_string<char> >' requested here
        declare_samplable_set<string>(m, "String");
        ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1422:60: note: declared private here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
                                                               ^
    In file included from src/bind_SamplableSetCR.cpp:27:
    src/SamplableSetCR.hpp:144:5: error: field of type 'typename PropensityGroup::iterator' (aka '__wrap_iter<std::__1::pair<std::__1::basic_string<char>, double> *>') has private constructor
        iterator_(NULL),
        ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:61:68: note: in instantiation of member function 'sset::SamplableSetCR<std::__1::basic_string<char> >::SamplableSetCR' requested here
    inline Class *construct_or_initialize(Args &&...args) { return new Class(std::forward<Args>(args)...); }
                                                                       ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:174:31: note: in instantiation of function template specialization 'pybind11::detail::initimpl::construct_or_initialize<sset::SamplableSetCR<std::__1::basic_string<char> >, const sset::SamplableSetCR<std::__1::basic_string<char> > &, 0>' requested here
                v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
                                  ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h:1148:14: note: in instantiation of function template specialization 'pybind11::detail::initimpl::constructor<const sset::SamplableSetCR<std::__1::basic_string<char> > &>::execute<pybind11::class_<sset::SamplableSetCR<std::__1::basic_string<char> >>, char [130], pybind11::arg, 0>' requested here
            init.execute(*this, extra...);
                 ^
    src/bind_SamplableSetCR.cpp:57:10: note: in instantiation of function template specialization 'pybind11::class_<sset::SamplableSetCR<std::__1::basic_string<char> >>::def<const sset::SamplableSetCR<std::__1::basic_string<char> > &, char [130], pybind11::arg>' requested here
            .def(py::init<const SamplableSetCR<T>&>(), R"pbdoc(
             ^
    src/bind_SamplableSetCR.cpp:139:5: note: in instantiation of function template specialization 'declare_samplable_set<std::__1::basic_string<char> >' requested here
        declare_samplable_set<string>(m, "String");
        ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1422:60: note: declared private here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
                                                               ^
    In file included from src/bind_SamplableSetCR.cpp:27:
    src/SamplableSetCR.hpp:161:5: error: field of type 'typename PropensityGroup::iterator' (aka '__wrap_iter<std::__1::pair<std::__1::basic_string<char>, double> *>') has private constructor
        iterator_(NULL),
        ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:61:68: note: in instantiation of member function 'sset::SamplableSetCR<std::__1::basic_string<char> >::SamplableSetCR' requested here
    inline Class *construct_or_initialize(Args &&...args) { return new Class(std::forward<Args>(args)...); }
                                                                       ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:174:31: note: in instantiation of function template specialization 'pybind11::detail::initimpl::construct_or_initialize<sset::SamplableSetCR<std::__1::basic_string<char> >, const sset::SamplableSetCR<std::__1::basic_string<char> > &, unsigned int, 0>' requested here
                v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
                                  ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h:1148:14: note: in instantiation of function template specialization 'pybind11::detail::initimpl::constructor<const sset::SamplableSetCR<std::__1::basic_string<char> > &, unsigned int>::execute<pybind11::class_<sset::SamplableSetCR<std::__1::basic_string<char> >>, char [170], pybind11::arg, pybind11::arg, 0>' requested here
            init.execute(*this, extra...);
                 ^
    src/bind_SamplableSetCR.cpp:64:10: note: in instantiation of function template specialization 'pybind11::class_<sset::SamplableSetCR<std::__1::basic_string<char> >>::def<const sset::SamplableSetCR<std::__1::basic_string<char> > &, unsigned int, char [170], pybind11::arg, pybind11::arg>' requested here
            .def(py::init<const SamplableSetCR<T>&, unsigned int>(), R"pbdoc(
             ^
    src/bind_SamplableSetCR.cpp:139:5: note: in instantiation of function template specialization 'declare_samplable_set<std::__1::basic_string<char> >' requested here
        declare_samplable_set<string>(m, "String");
        ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1422:60: note: declared private here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
                                                               ^
    In file included from src/bind_SamplableSetCR.cpp:27:
    src/SamplableSetCR.hpp:119:5: error: field of type 'typename PropensityGroup::iterator' (aka '__wrap_iter<std::__1::pair<std::__1::tuple<int, int, int>, double> *>') has private constructor
        iterator_(NULL),
        ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:61:68: note: in instantiation of member function 'sset::SamplableSetCR<std::__1::tuple<int, int, int> >::SamplableSetCR' requested here
    inline Class *construct_or_initialize(Args &&...args) { return new Class(std::forward<Args>(args)...); }
                                                                       ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:174:31: note: in instantiation of function template specialization 'pybind11::detail::initimpl::construct_or_initialize<sset::SamplableSetCR<std::__1::tuple<int, int, int> >, double, double, unsigned int, 0>' requested here
                v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
                                  ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h:1148:14: note: in instantiation of function template specialization 'pybind11::detail::initimpl::constructor<double, double, unsigned int>::execute<pybind11::class_<sset::SamplableSetCR<std::__1::tuple<int, int, int> >>, char [252], pybind11::arg, pybind11::arg, pybind11::arg_v, 0>' requested here
            init.execute(*this, extra...);
                 ^
    src/bind_SamplableSetCR.cpp:47:10: note: in instantiation of function template specialization 'pybind11::class_<sset::SamplableSetCR<std::__1::tuple<int, int, int> >>::def<double, double, unsigned int, char [252], pybind11::arg, pybind11::arg, pybind11::arg_v>' requested here
            .def(py::init<double, double, unsigned int>(), R"pbdoc(
             ^
    src/bind_SamplableSetCR.cpp:140:5: note: in instantiation of function template specialization 'declare_samplable_set<std::__1::tuple<int, int, int> >' requested here
        declare_samplable_set<Edge>(m, "Edge");
        ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1422:60: note: declared private here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
                                                               ^
    In file included from src/bind_SamplableSetCR.cpp:27:
    src/SamplableSetCR.hpp:144:5: error: field of type 'typename PropensityGroup::iterator' (aka '__wrap_iter<std::__1::pair<std::__1::tuple<int, int, int>, double> *>') has private constructor
        iterator_(NULL),
        ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:61:68: note: in instantiation of member function 'sset::SamplableSetCR<std::__1::tuple<int, int, int> >::SamplableSetCR' requested here
    inline Class *construct_or_initialize(Args &&...args) { return new Class(std::forward<Args>(args)...); }
                                                                       ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:174:31: note: in instantiation of function template specialization 'pybind11::detail::initimpl::construct_or_initialize<sset::SamplableSetCR<std::__1::tuple<int, int, int> >, const sset::SamplableSetCR<std::__1::tuple<int, int, int> > &, 0>' requested here
                v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
                                  ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h:1148:14: note: in instantiation of function template specialization 'pybind11::detail::initimpl::constructor<const sset::SamplableSetCR<std::__1::tuple<int, int, int> > &>::execute<pybind11::class_<sset::SamplableSetCR<std::__1::tuple<int, int, int> >>, char [130], pybind11::arg, 0>' requested here
            init.execute(*this, extra...);
                 ^
    src/bind_SamplableSetCR.cpp:57:10: note: in instantiation of function template specialization 'pybind11::class_<sset::SamplableSetCR<std::__1::tuple<int, int, int> >>::def<const sset::SamplableSetCR<std::__1::tuple<int, int, int> > &, char [130], pybind11::arg>' requested here
            .def(py::init<const SamplableSetCR<T>&>(), R"pbdoc(
             ^
    src/bind_SamplableSetCR.cpp:140:5: note: in instantiation of function template specialization 'declare_samplable_set<std::__1::tuple<int, int, int> >' requested here
        declare_samplable_set<Edge>(m, "Edge");
        ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1422:60: note: declared private here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
                                                               ^
    In file included from src/bind_SamplableSetCR.cpp:27:
    src/SamplableSetCR.hpp:161:5: error: field of type 'typename PropensityGroup::iterator' (aka '__wrap_iter<std::__1::pair<std::__1::tuple<int, int, int>, double> *>') has private constructor
        iterator_(NULL),
        ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:61:68: note: in instantiation of member function 'sset::SamplableSetCR<std::__1::tuple<int, int, int> >::SamplableSetCR' requested here
    inline Class *construct_or_initialize(Args &&...args) { return new Class(std::forward<Args>(args)...); }
                                                                       ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:174:31: note: in instantiation of function template specialization 'pybind11::detail::initimpl::construct_or_initialize<sset::SamplableSetCR<std::__1::tuple<int, int, int> >, const sset::SamplableSetCR<std::__1::tuple<int, int, int> > &, unsigned int, 0>' requested here
                v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
                                  ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h:1148:14: note: in instantiation of function template specialization 'pybind11::detail::initimpl::constructor<const sset::SamplableSetCR<std::__1::tuple<int, int, int> > &, unsigned int>::execute<pybind11::class_<sset::SamplableSetCR<std::__1::tuple<int, int, int> >>, char [170], pybind11::arg, pybind11::arg, 0>' requested here
            init.execute(*this, extra...);
                 ^
    src/bind_SamplableSetCR.cpp:64:10: note: in instantiation of function template specialization 'pybind11::class_<sset::SamplableSetCR<std::__1::tuple<int, int, int> >>::def<const sset::SamplableSetCR<std::__1::tuple<int, int, int> > &, unsigned int, char [170], pybind11::arg, pybind11::arg>' requested here
            .def(py::init<const SamplableSetCR<T>&, unsigned int>(), R"pbdoc(
             ^
    src/bind_SamplableSetCR.cpp:140:5: note: in instantiation of function template specialization 'declare_samplable_set<std::__1::tuple<int, int, int> >' requested here
        declare_samplable_set<Edge>(m, "Edge");
        ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1422:60: note: declared private here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
                                                               ^
    In file included from src/bind_SamplableSetCR.cpp:27:
    src/SamplableSetCR.hpp:119:5: error: field of type 'typename PropensityGroup::iterator' (aka '__wrap_iter<std::__1::pair<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> >, double> *>') has private constructor
        iterator_(NULL),
        ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:61:68: note: in instantiation of member function 'sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > >::SamplableSetCR' requested here
    inline Class *construct_or_initialize(Args &&...args) { return new Class(std::forward<Args>(args)...); }
                                                                       ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:174:31: note: in instantiation of function template specialization 'pybind11::detail::initimpl::construct_or_initialize<sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > >, double, double, unsigned int, 0>' requested here
                v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
                                  ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h:1148:14: note: in instantiation of function template specialization 'pybind11::detail::initimpl::constructor<double, double, unsigned int>::execute<pybind11::class_<sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > >>, char [252], pybind11::arg, pybind11::arg, pybind11::arg_v, 0>' requested here
            init.execute(*this, extra...);
                 ^
    src/bind_SamplableSetCR.cpp:47:10: note: in instantiation of function template specialization 'pybind11::class_<sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > >>::def<double, double, unsigned int, char [252], pybind11::arg, pybind11::arg, pybind11::arg_v>' requested here
            .def(py::init<double, double, unsigned int>(), R"pbdoc(
             ^
    src/bind_SamplableSetCR.cpp:141:5: note: in instantiation of function template specialization 'declare_samplable_set<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > >' requested here
        declare_samplable_set<DoubleEdge>(m, "DoubleEdge");
        ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1422:60: note: declared private here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
                                                               ^
    In file included from src/bind_SamplableSetCR.cpp:27:
    src/SamplableSetCR.hpp:144:5: error: field of type 'typename PropensityGroup::iterator' (aka '__wrap_iter<std::__1::pair<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> >, double> *>') has private constructor
        iterator_(NULL),
        ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:61:68: note: in instantiation of member function 'sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > >::SamplableSetCR' requested here
    inline Class *construct_or_initialize(Args &&...args) { return new Class(std::forward<Args>(args)...); }
                                                                       ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:174:31: note: in instantiation of function template specialization 'pybind11::detail::initimpl::construct_or_initialize<sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > >, const sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > > &, 0>' requested here
                v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
                                  ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h:1148:14: note: in instantiation of function template specialization 'pybind11::detail::initimpl::constructor<const sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > > &>::execute<pybind11::class_<sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > >>, char [130], pybind11::arg, 0>' requested here
            init.execute(*this, extra...);
                 ^
    src/bind_SamplableSetCR.cpp:57:10: note: in instantiation of function template specialization 'pybind11::class_<sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > >>::def<const sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > > &, char [130], pybind11::arg>' requested here
            .def(py::init<const SamplableSetCR<T>&>(), R"pbdoc(
             ^
    src/bind_SamplableSetCR.cpp:141:5: note: in instantiation of function template specialization 'declare_samplable_set<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > >' requested here
        declare_samplable_set<DoubleEdge>(m, "DoubleEdge");
        ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1422:60: note: declared private here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
                                                               ^
    In file included from src/bind_SamplableSetCR.cpp:27:
    src/SamplableSetCR.hpp:161:5: error: field of type 'typename PropensityGroup::iterator' (aka '__wrap_iter<std::__1::pair<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> >, double> *>') has private constructor
        iterator_(NULL),
        ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:61:68: note: in instantiation of member function 'sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > >::SamplableSetCR' requested here
    inline Class *construct_or_initialize(Args &&...args) { return new Class(std::forward<Args>(args)...); }
                                                                       ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:174:31: note: in instantiation of function template specialization 'pybind11::detail::initimpl::construct_or_initialize<sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > >, const sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > > &, unsigned int, 0>' requested here
                v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
                                  ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h:1148:14: note: in instantiation of function template specialization 'pybind11::detail::initimpl::constructor<const sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > > &, unsigned int>::execute<pybind11::class_<sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > >>, char [170], pybind11::arg, pybind11::arg, 0>' requested here
            init.execute(*this, extra...);
                 ^
    src/bind_SamplableSetCR.cpp:64:10: note: in instantiation of function template specialization 'pybind11::class_<sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > >>::def<const sset::SamplableSetCR<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > > &, unsigned int, char [170], pybind11::arg, pybind11::arg>' requested here
            .def(py::init<const SamplableSetCR<T>&, unsigned int>(), R"pbdoc(
             ^
    src/bind_SamplableSetCR.cpp:141:5: note: in instantiation of function template specialization 'declare_samplable_set<std::__1::tuple<std::__1::tuple<int, int>, std::__1::tuple<int, int> > >' requested here
        declare_samplable_set<DoubleEdge>(m, "DoubleEdge");
        ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1422:60: note: declared private here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
                                                               ^
    In file included from src/bind_SamplableSetCR.cpp:27:
    src/SamplableSetCR.hpp:119:5: error: field of type 'typename PropensityGroup::iterator' (aka '__wrap_iter<std::__1::pair<std::__1::tuple<int, int>, double> *>') has private constructor
        iterator_(NULL),
        ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:61:68: note: in instantiation of member function 'sset::SamplableSetCR<std::__1::tuple<int, int> >::SamplableSetCR' requested here
    inline Class *construct_or_initialize(Args &&...args) { return new Class(std::forward<Args>(args)...); }
                                                                       ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:174:31: note: in instantiation of function template specialization 'pybind11::detail::initimpl::construct_or_initialize<sset::SamplableSetCR<std::__1::tuple<int, int> >, double, double, unsigned int, 0>' requested here
                v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
                                  ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h:1148:14: note: in instantiation of function template specialization 'pybind11::detail::initimpl::constructor<double, double, unsigned int>::execute<pybind11::class_<sset::SamplableSetCR<std::__1::tuple<int, int> >>, char [252], pybind11::arg, pybind11::arg, pybind11::arg_v, 0>' requested here
            init.execute(*this, extra...);
                 ^
    src/bind_SamplableSetCR.cpp:47:10: note: in instantiation of function template specialization 'pybind11::class_<sset::SamplableSetCR<std::__1::tuple<int, int> >>::def<double, double, unsigned int, char [252], pybind11::arg, pybind11::arg, pybind11::arg_v>' requested here
            .def(py::init<double, double, unsigned int>(), R"pbdoc(
             ^
    src/bind_SamplableSetCR.cpp:142:5: note: in instantiation of function template specialization 'declare_samplable_set<std::__1::tuple<int, int> >' requested here
        declare_samplable_set<DoubleInt>(m, "DoubleInt");
        ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1422:60: note: declared private here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
                                                               ^
    In file included from src/bind_SamplableSetCR.cpp:27:
    src/SamplableSetCR.hpp:144:5: error: field of type 'typename PropensityGroup::iterator' (aka '__wrap_iter<std::__1::pair<std::__1::tuple<int, int>, double> *>') has private constructor
        iterator_(NULL),
        ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:61:68: note: in instantiation of member function 'sset::SamplableSetCR<std::__1::tuple<int, int> >::SamplableSetCR' requested here
    inline Class *construct_or_initialize(Args &&...args) { return new Class(std::forward<Args>(args)...); }
                                                                       ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:174:31: note: in instantiation of function template specialization 'pybind11::detail::initimpl::construct_or_initialize<sset::SamplableSetCR<std::__1::tuple<int, int> >, const sset::SamplableSetCR<std::__1::tuple<int, int> > &, 0>' requested here
                v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
                                  ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h:1148:14: note: in instantiation of function template specialization 'pybind11::detail::initimpl::constructor<const sset::SamplableSetCR<std::__1::tuple<int, int> > &>::execute<pybind11::class_<sset::SamplableSetCR<std::__1::tuple<int, int> >>, char [130], pybind11::arg, 0>' requested here
            init.execute(*this, extra...);
                 ^
    src/bind_SamplableSetCR.cpp:57:10: note: in instantiation of function template specialization 'pybind11::class_<sset::SamplableSetCR<std::__1::tuple<int, int> >>::def<const sset::SamplableSetCR<std::__1::tuple<int, int> > &, char [130], pybind11::arg>' requested here
            .def(py::init<const SamplableSetCR<T>&>(), R"pbdoc(
             ^
    src/bind_SamplableSetCR.cpp:142:5: note: in instantiation of function template specialization 'declare_samplable_set<std::__1::tuple<int, int> >' requested here
        declare_samplable_set<DoubleInt>(m, "DoubleInt");
        ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1422:60: note: declared private here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
                                                               ^
    In file included from src/bind_SamplableSetCR.cpp:27:
    src/SamplableSetCR.hpp:161:5: error: field of type 'typename PropensityGroup::iterator' (aka '__wrap_iter<std::__1::pair<std::__1::tuple<int, int>, double> *>') has private constructor
        iterator_(NULL),
        ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:61:68: note: in instantiation of member function 'sset::SamplableSetCR<std::__1::tuple<int, int> >::SamplableSetCR' requested here
    inline Class *construct_or_initialize(Args &&...args) { return new Class(std::forward<Args>(args)...); }
                                                                       ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/detail/init.h:174:31: note: in instantiation of function template specialization 'pybind11::detail::initimpl::construct_or_initialize<sset::SamplableSetCR<std::__1::tuple<int, int> >, const sset::SamplableSetCR<std::__1::tuple<int, int> > &, unsigned int, 0>' requested here
                v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
                                  ^
    /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h:1148:14: note: in instantiation of function template specialization 'pybind11::detail::initimpl::constructor<const sset::SamplableSetCR<std::__1::tuple<int, int> > &, unsigned int>::execute<pybind11::class_<sset::SamplableSetCR<std::__1::tuple<int, int> >>, char [170], pybind11::arg, pybind11::arg, 0>' requested here
            init.execute(*this, extra...);
                 ^
    src/bind_SamplableSetCR.cpp:64:10: note: in instantiation of function template specialization 'pybind11::class_<sset::SamplableSetCR<std::__1::tuple<int, int> >>::def<const sset::SamplableSetCR<std::__1::tuple<int, int> > &, unsigned int, char [170], pybind11::arg, pybind11::arg>' requested here
            .def(py::init<const SamplableSetCR<T>&, unsigned int>(), R"pbdoc(
             ^
    src/bind_SamplableSetCR.cpp:142:5: note: in instantiation of function template specialization 'declare_samplable_set<std::__1::tuple<int, int> >' requested here
        declare_samplable_set<DoubleInt>(m, "DoubleInt");
        ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1422:60: note: declared private here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
                                                               ^
    15 errors generated.
    error: command '/usr/bin/clang' failed with exit status 1

    ----------------------------------------
Command "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -c "import setuptools, tokenize;__file__='/Users/bfmaier/pythonlib/SamplableSet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" develop --no-deps" failed with error code 1 in /Users/bfmaier/pythonlib/SamplableSet/

'Cannot infer the type from the element' on integer element

Here's a fun one. I'm trying to construct neighbor sampling sets from a network I generated using numpy.

I initiate a set like so:

SamplableSet(1,1,neighbors,cpp_type='int')

where neighbors might look something like

{480: 1.0, 479: 1.0, 476: 1.0}

I'm getting the error

Cannot infer the type from the element

Problem: I was generating edges from a node list that is a numpy array with type numpy.in64. And SamplableSet doesn't like that :)

Solution

Converting element integers from numpy.in64 to Python native int.

Not sure if there needs to be something changed in this package. I just thought I open this issue so that people can find it when they encounter the same error. I'll close the issue right after posting, feel free to reopen it if it is indeed an issue.

C++11 compatibility

Many people are still using compilers that do not comply with c++17, and are not willing to do the upgrade. Since few features of c++17 are in use, it might be a good idea to make it compatible with c++11.

Rounding errors when sampling at multiple scales

Weights are represented in double floating-point format. If the ratio of maximal over minimal weight is equal or larger to ~ 1e16, then rounding errors become much more important. As a result, the SamplableSet might try to access a container with empty elements.

This can also happen if the ratio is smaller than 1e16, but if elements are inserted and removed a lot.

v2.0: error: 'seed' is a protected member of 'sset::BaseSamplableSet'

getting compile errors on macOS again

    Complete output from command /opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-req-build-omvpayv_/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/tmp/pip-record-kv0vu5az/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.14-x86_64-3.7
    creating build/lib.macosx-10.14-x86_64-3.7/SamplableSet
    copying SamplableSet/_wrapper.py -> build/lib.macosx-10.14-x86_64-3.7/SamplableSet
    copying SamplableSet/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/SamplableSet
    running build_ext
    creating tmp
    /usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -I/opt/local/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c /tmp/tmpn3hs53z7.cpp -o tmp/tmpn3hs53z7.o -std=c++17
    /usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -I/opt/local/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c /tmp/tmpndbin40v.cpp -o tmp/tmpndbin40v.o -fvisibility=hidden
    building '_SamplableSet' extension
    creating build/temp.macosx-10.14-x86_64-3.7
    creating build/temp.macosx-10.14-x86_64-3.7/src
    /usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -Isrc/ -I/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c src/bind_SamplableSet.cpp -o build/temp.macosx-10.14-x86_64-3.7/src/bind_SamplableSet.o -stdlib=libc++ -mmacosx-version-min=10.7 -DVERSION_INFO="2.0.0" -std=c++17 -fvisibility=hidden
    src/bind_SamplableSet.cpp:86:48: error: 'seed' is a protected member of 'sset::BaseSamplableSet'
            .def_static("seed", &BaseSamplableSet::seed, R"pbdoc(
                                                   ^
    src/SamplableSet.hpp:51:21: note: declared protected here
            static void seed(unsigned int seed_value);
                        ^
    1 error generated.
    error: command '/usr/bin/clang' failed with exit status 1```

IndexError: vector

Hi, I've gotten this error for the first time since I've started using SamplableSet, any idea what might cause this?

/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/SamplableSet/_wrapper.py in sample(self, n_samples, replace)
    140         """
    141         if n_samples == 1:
--> 142             x = self._samplable_set.sample()
    143             if not replace and x is not None:
    144                 self._samplable_set.erase(x[0])

IndexError: vector

empty set raises problems

Hey Guillaume!
Constructing an empty set seems to cause problems now. see here:

In [1]: from SamplableSet import SamplableSet

In [2]: min_weight = 1; max_weight=1; neighbors = {};

In [3]: SamplableSet(min_weight,max_weight,neighbors)
Out[3]: ---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/usr/local/lib/python3.8/site-packages/IPython/core/formatters.py in __call__(self, obj)
    700                 type_pprinters=self.type_printers,
    701                 deferred_pprinters=self.deferred_printers)
--> 702             printer.pretty(obj)
    703             printer.flush()
    704             return stream.getvalue()

/usr/local/lib/python3.8/site-packages/IPython/lib/pretty.py in pretty(self, obj)
    392                         if cls is not object \
    393                                 and callable(cls.__dict__.get('__repr__')):
--> 394                             return _repr_pprint(obj, self, cycle)
    395
    396             return _default_pprint(obj, self, cycle)

/usr/local/lib/python3.8/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle)
    698     """A pprint that just redirects to the normal repr function."""
    699     # Find newlines and replace them with p.break_()
--> 700     output = repr(obj)
    701     lines = output.splitlines()
    702     with p.group():

/usr/local/lib/python3.8/site-packages/SamplableSet/_wrapper.py in __repr__(self)
    136
    137     def __repr__(self):
--> 138         return str(self)
    139
    140     def __len__(self):

/usr/local/lib/python3.8/site-packages/SamplableSet/_wrapper.py in __str__(self)
    133
    134     def __str__(self):
--> 135         return f'SamplableSet of {len(self)} element' + ('s' if len(self) > 1 else '')
    136
    137     def __repr__(self):

/usr/local/lib/python3.8/site-packages/SamplableSet/_wrapper.py in __len__(self)
    139
    140     def __len__(self):
--> 141         return self.size()
    142
    143     def copy(self):

AttributeError: 'SamplableSet' object has no attribute 'size'

I think this worked before because cpp_type=int was implicit but now it tries to infer the type? Is this behavior intentional?

btw, it works fine when I call

SamplableSet(min_weight,max_weight,{},cpp_type="int")

Cheers!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.