// $Id$ // // Copyright (C) 2005-2006 Rational Discovery LLC // @@ All Rights Reserved @@ // This file is part of the RDKit. // The contents are covered by the terms of the BSD license // which is included in the file license.txt, found at the root // of the RDKit source tree. // #include #include #include #include namespace python = boost::python; #include "fastentropy.h" template PyObject *runCMIM(python::list examples,unsigned int nToTake){ //std::cerr << "select " << std::endl;std::cerr.flush(); unsigned int nExamples=python::extract(examples.attr("__len__")()); //std::cerr << "NEX " << nExamples << std::endl;std::cerr.flush(); python::list example=python::extract(examples[0]); const BV &tmpBV=python::extract(example[1]); unsigned int exSize=python::extract(example.attr("__len__")()); //std::cerr << "EXSIZE " << exSize << std::endl;std::cerr.flush(); unsigned int nBits=tmpBV.getNumBits(); //std::cerr << "nBits " << nBits << std::endl;std::cerr.flush(); unsigned int sz=(nExamples+31)/32; uint32_t *y = new uint32_t[sz]; memset(y,0,sizeof(uint32_t)*sz); uint32_t *raw = new uint32_t[sz*nBits]; memset(raw,0,sizeof(uint32_t)*sz*nBits); uint32_t **x = new uint32_t *[nBits]; for(unsigned int i=0;i(examples[i]); fe_set_bit(i,y,python::extract(example[exSize-1])>0); const BV &bv=python::extract(example[1]); //std::cerr << BitVectToText(bv) << std::endl; for(unsigned int j=0;j(examples[0]); python::extract conv(example[1]); if(conv.check()){ res = runCMIM(examples,nToTake); } else { res = runCMIM(examples,nToTake); } return res; } BOOST_PYTHON_MODULE(rdFeatSelect) { fe_init_tables(); python::scope().attr("__doc__") = "Module containing functions for feature selection" ; std::string docString=""; python::def("selectCMIM", selectCMIM, docString.c_str()); }