Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Division by 0 in alinging two lines with rotation_matrix(a, b) #1747
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<python3.6 dir>/site-packages/MDAnalysis/analysis/align.py", line 276, in rotation_matrix rmsd = qcp.CalcRMSDRotationalMatrix(a, b, N, rot, weights) File "MDAnalysis/lib/qcprot.pyx", line 286, in MDAnalysis.lib.qcprot.CalcRMSDRotationalMatrix (MDAnalysis/lib/qcprot.c:2764) File "MDAnalysis/lib/qcprot.pyx", line 387, in MDAnalysis.lib.qcprot.FastCalcRMSDAndRotation (MDAnalysis/lib/qcprot.c:3625) ZeroDivisionError: float division
Code to reproduce the behaviour
import numpy as np from MDAnalysis.analysis.align import rotation_matrix dtype = np.float32 # np.float64 gives same error a = np.array([[0.13662023, -0.39526145, 0.75835566], [-0.13662023, 0.39526145, -0.75835566]], dtype=dtype) b = np.array([[-0.30452963, 0.78899221, -0.18642158], [0.30452963, -0.78899221, 0.18642158]], dtype=dtype) R, rmsd = rotation_matrix(a, b) # division by zero
Current version of MDAnalysis:
$ python3 -c "import MDAnalysis as mda; print(mda.__version__)" Warning: ##### MDAnalysis on python 3 is highly experimental! It is mostly non functional and dramatically untested. Use at your own risks!!! ''') 0.16.2
I tried python 2, and the test code gives the same error.
Does that mean the division by 0 is caused by having a 0 derivative in the Newton-Raphson method?