Repository navigation
Fix rotation orientation and scale in Procrustes with reflection=False - #302
Conversation
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
|
Thanks so much for this contribution, @chenyangsu! This was a real bug and a clean fix. We reviewed it independently before merging:
On your 1D question: yes, we think clamping is right, i.e. A few other optional follow-ups, none blocking, if you're interested:
Thanks again! Generated by Claude Code |
In
procrustes.align(..., reflection=False),np.dot(u[:, :nsv] * s, vh)returns the transposed rotation and overwritessbeforess = sum(s). On a 3D 90-degree rotationR,alignreturns3 * R.T; on a 2D reflection,ssbecomes0.0andalignreturns zeros.Using a sign vector
dfort = np.dot(vh.T * d, u.T)andss = float(np.sum(s * d))matches Schonemann (1966) and Umeyama (1991), with tests intests/test_procrustes.py. Happy to clampssat zero for 1D inputs if you prefer.Testing:
pytest -q tests/test_procrustes.py tests/align/ -k "not test_procrustes_func"(56 passed);ruff check(clean).