consolidate numeric vectors (#7792)

* Speed up boost vector iterators by 300x

* Add vector testing code

* Update test

* Remove GetPosition notebook

* Move all wrapped int vectors to top level

* Grab MatchTypeVect from rdBase

* Actually wrap the vectors
This commit is contained in:
Brian Kelley
2024-09-18 01:43:17 -04:00
committed by GitHub
parent 9824a9d964
commit c8cd4e7c20
6 changed files with 14 additions and 9 deletions

View File

@@ -142,8 +142,6 @@ struct enumeration_wrapper {
static void wrap() {
std::string docString;
RegisterVectorConverter<std::vector<std::string>>("VectorOfStringVectors");
RegisterVectorConverter<boost::uint64_t>("VectSizeT");
RegisterVectorConverter<MOL_SPTR_VECT>("VectMolVect");
python::class_<RDKit::EnumerateLibraryBase, RDKit::EnumerateLibraryBase *,

View File

@@ -322,8 +322,6 @@ struct filtercat_wrapper {
.def_readwrite("target", &std::pair<int, int>::second)
.def("__getitem__", &GetMatchVectItem, python::args("self", "idx"));
RegisterVectorConverter<std::pair<int, int>>("MatchTypeVect");
python::class_<FilterMatch, boost::shared_ptr<FilterMatch>>(
"FilterMatch", FilterMatchDoc,
python::init<boost::shared_ptr<FilterMatcherBase>, MatchVectType>(

View File

@@ -169,8 +169,6 @@ python::object TQToBinary(const TautomerQuery &tq) {
struct TautomerQuery_wrapper {
static void wrap() {
RegisterVectorConverter<size_t>("UnsignedLong_Vect");
auto docString =
"The Tautomer Query Class.\n\
Creates a query that enables structure search accounting for matching of\n\

View File

@@ -257,11 +257,20 @@ BOOST_PYTHON_MODULE(rdBase) {
RDLog::InitLogs();
RegisterVectorConverter<int>();
RegisterVectorConverter<unsigned>();
RegisterVectorConverter<size_t>("UnsignedLong_Vect");
RegisterVectorConverter<boost::uint64_t>("VectSizeT");
RegisterVectorConverter<double>();
RegisterVectorConverter<std::string>(1);
RegisterVectorConverter<std::vector<int>>();
RegisterVectorConverter<std::vector<unsigned>>();
RegisterVectorConverter<std::vector<double>>();
RegisterVectorConverter<std::vector<std::string>>("VectorOfStringVectors");
RegisterVectorConverter<std::pair<int, int>>("MatchTypeVect");
path_converter();
RegisterListConverter<int>();

View File

@@ -8,9 +8,9 @@
#
import sys
from rdkit import Chem
from rdkit import Chem, rdBase
from rdkit.Chem.rdfiltercatalog import *
MatchTypeVect = rdBase.MatchTypeVect
class FilterMatcher(PythonFilterMatcher):
"""FilterMatcher - This class allows creation of Python based

View File

@@ -59,8 +59,10 @@ class VectIter:
def __vect__iter__(vect):
return VectIter(vect)
VECT_WRAPS = {'MatchTypeVect', 'UnsignedLong_Vect', 'VectSizeT', 'VectorOfStringVectors'}
for name, object in vars(rdBase).items():
if name.startswith("_list") or name.startswith("_vect"):
if name.startswith("_list") or name.startswith("_vect") or name in VECT_WRAPS:
if hasattr(object, "__iter__"):
object.__iter__ = __vect__iter__