// $Id$ // // Copyright (C) 2007 Greg Landrum // // @@ All Rights Reserved @@ // #include #include #include #include #include using namespace RDKit; template struct siv_pickle_suite : python::pickle_suite { static python::tuple getinitargs(const SparseIntVect& self) { return python::make_tuple(self.toString()); }; }; namespace { template void pyUpdateFromSequence(SparseIntVect &vect, python::object &seq){ PySequenceHolder seqL(seq); for(unsigned int i=0;i static void wrapOne(const char *className){ python::class_ >(className, sparseIntVectDoc.c_str(), python::init("Constructor")) .def(python::init()) .def("__len__", &SparseIntVect::getLength, "Get the number of entries in the vector") .def("__setitem__", &SparseIntVect::setVal, "Set the value at a specified location") .def("__getitem__", &SparseIntVect::getVal, "Get the value at a specified location") .def(python::self & python::self) .def(python::self | python::self) .def(python::self - python::self) .def(python::self -= python::self) .def(python::self + python::self) .def(python::self += python::self) .def(python::self == python::self) .def(python::self != python::self) .def("GetTotalVal", &SparseIntVect::getTotalVal, (python::args("useAbs")=false), "Get the sum of the values in the vector, basically L1 norm") .def("ToBinary", &SparseIntVect::toString, "returns a binary (pickle) representation of the vector") .def("UpdateFromSequence", &pyUpdateFromSequence, "update the vector based on the values in the list or tuple") .def_pickle(siv_pickle_suite()) ; } static void wrap() { wrapOne("IntSparseIntVect"); wrapOne("LongSparseIntVect"); } }; void wrap_sparseIntVect() { sparseIntVec_wrapper::wrap(); }