mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
Throw when attempting to normalize a Zero RDGeom::Point (#8008)
* throw if close to zero * fix moldraw2DTestCatch * Fix testRGroupDecomp * fix one test in distGeomHelpersCatch * fix tests in distGeomHelpersCatch * retry finding a dir vector when adding Hs * push UFF fixes to calculateCosY * fix the setTerminalAtomCoords deg 4 patch * add a test * reduce zero tolerance
This commit is contained in:
committed by
GitHub
parent
ffb100d928
commit
39d4662ae7
@@ -22,6 +22,8 @@
|
||||
#include <boost/random.hpp>
|
||||
#include <boost/smart_ptr.hpp>
|
||||
|
||||
static constexpr double zero_tolerance = 1.e-16;
|
||||
|
||||
namespace RDNumeric {
|
||||
|
||||
//! A class to represent vectors of numbers.
|
||||
@@ -260,6 +262,9 @@ class Vector {
|
||||
//! Normalize the vector using the L2 norm
|
||||
inline void normalize() {
|
||||
TYPE val = this->normL2();
|
||||
if (val < zero_tolerance) {
|
||||
throw std::runtime_error("Cannot normalize a zero length vector");
|
||||
}
|
||||
(*this) /= val;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user