imp icon indicating copy to clipboard operation
imp copied to clipboard

VectorD checks don't appear to work

Open benmwebb opened this issue 10 years ago • 0 comments

Most operations on a VectorD are usage-checked (see IMP_ALGEBRA_VECTOR_CHECK* in VectorBaseD.h) to make sure we're not using a default-constructed vector. But they don't seem to work:

module load imp
python
>>> import IMP.algebra
>>> v = IMP.algebra.Vector3D()
>>> v
(nan, nan, nan)
>>> v[0]

The v[0] should trigger a check of the vector and fail with Attempt to use uninitialized vector.

The copy constructor does seem to check correctly:

>>> v2 = IMP.algebra.Vector3D(v)
Traceback (most recent call last):
...
_IMP_base.UsageException: Usage check failure: NaN passed to constructor

This is probably because internal::VectorData::get_is_null() tries to compare the vector value against the "null" value (NaN) and NaNs tend not to perform sanely in such comparisons (e.g. nan == nan is False in Python at least).

benmwebb avatar Aug 18 '14 21:08 benmwebb