mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
* Add RealValueVect.
* Add UniformRealValueGrid3D
* Add Molecular Interaction Fields (MIFs)
* line endings
* cherry-pick f1bc94a4c8
* format
* Adapt tests for python3.
* Adapt RealValueVector pickling for python3.
* Speed-up of MIF calculations.
* Bugfix in MIFDescriptors.cpp.
* all tests pass
* clean up some memory leaks
* update copyrights
* rename
* rename the library
* complete the rename
* lost file
* another forgotten file
* cleanup
* clang-tidy
* clang-tidy
* windows DLL builds work
* python wrapper and tests cleanup
* convert to catch2 testing
* switch RealValueVect to use std::vector
* remove obsolete friend
* - Replace explicit loops with stdlib implicit equivalents
- Replace explicit types with auto where possible
- Avoid unnecessary copy operations where possible
- Replace raw pointers with exception-safe unique_ptr
- Replace C-style #define with constexpr
- Replace C-style casts with C++ casts
- Replace C-style arrays with std::vector
- Avoid code duplication with templated operators
- Replace VdWaals class taking multiple atom type definitions and force-field name as string parameter with force-field-specific classes deriving from an abstract VdWaals class
- Replace x,y,z doubles with Point3D class where possible
- Removed unused (and untested) DistanceToClosestAtom class
- Renamed some variables and functions for better clarity
- Converted tabs to spaces
- Made the mol parameter in cube read/write functions optional for convenience
- Made the Python wrappers more pythonic (e.g., avoid C++-style passing objects as parameters which are modified in place)
- Implemented alternative Python class constructors using boost::python::make_constructor rather than with external non-class functions
- The Python wrappers taking a sequence of Point3D now take a sequence of sequences, such that the output of Conformer.GetPositions() can be passed
- Made the Python wrapper sequence parsing more robust
- Removed duplicated code from Python wrappers
* - avoid an unnecessary copy
* progress
* works
* more cleanup
* all tests pass
* changes in response to review
---------
Co-authored-by: dfhahn <dfhahn@users.noreply.github.com>
Co-authored-by: ptosco <paolo.tosco@novartis.com>
74 lines
2.6 KiB
C++
Executable File
74 lines
2.6 KiB
C++
Executable File
//
|
|
// Copyright (c) 2014-2024, Novartis Institutes for BioMedical Research and
|
|
// other RDKit contributors
|
|
//
|
|
// @@ 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 <boost/python.hpp>
|
|
|
|
#include <RDGeneral/types.h>
|
|
#include <RDGeneral/Invariant.h>
|
|
#include <RDBoost/PySequenceHolder.h>
|
|
#include <DataStructs/RealValueVect.h>
|
|
|
|
using namespace RDKit;
|
|
|
|
struct rvv_pickle_suite : rdkit_pickle_suite {
|
|
static python::tuple getinitargs(const RealValueVect &self) {
|
|
std::string res = self.toString();
|
|
python::object retval = python::object(
|
|
python::handle<>(PyBytes_FromStringAndSize(res.c_str(), res.length())));
|
|
return python::make_tuple(retval);
|
|
};
|
|
};
|
|
|
|
std::string realValVectDoc =
|
|
"A container class for storing real\n\
|
|
values.\n\
|
|
\n\
|
|
The length of the vector is set at construction time.\n\
|
|
\n\
|
|
As you would expect, _RealValueVects_ support a set of binary operations\n\
|
|
so you can do things like:\n\
|
|
rvv3 = rvv1 & rvv2 the result contains the smallest value in each entry\n\
|
|
rvv3 = rvv1 | rvv2 the result contains the largest value in each entry\n\
|
|
rvv1 += rvv2 \n\
|
|
rvv3 = rvv1 + rvv2 \n\
|
|
rvv1 -= rvv3 \n\
|
|
rvv3 = rvv1 - rvv2 \n\
|
|
\n\
|
|
Elements can be set and read using indexing (i.e. bv[i] = 4 or val=bv[i])\n\
|
|
\n";
|
|
|
|
struct realValVec_wrapper {
|
|
static void wrap() {
|
|
python::class_<RealValueVect>("RealValueVect", realValVectDoc.c_str(),
|
|
python::init<unsigned int>("Constructor"))
|
|
.def(python::init<std::string>())
|
|
.def("__len__", &RealValueVect::getLength,
|
|
"Get the number of entries in the vector")
|
|
.def("__setitem__", &RealValueVect::setVal,
|
|
"Set the value at a specified location")
|
|
.def("__getitem__", &RealValueVect::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("GetTotalVal", &RealValueVect::getTotalVal,
|
|
"Get the sum of the values in the vector, basically L1 norm")
|
|
.def_pickle(rvv_pickle_suite());
|
|
python::def("ComputeL1Norm", computeL1Norm,
|
|
"Compute the distance between two real vector values\n");
|
|
}
|
|
};
|
|
|
|
void wrap_realValVect() { realValVec_wrapper::wrap(); }
|