Skip to content

Fix rotation orientation and scale in Procrustes with reflection=False - #302

Open
chenyangsu wants to merge 1 commit into
ContextLab:masterfrom
chenyangsu:fix/procrustes-no-reflection
Open

chenyangsu wants to merge 1 commit into
ContextLab:masterfrom
chenyangsu:fix/procrustes-no-reflection

Conversation

@chenyangsu

Copy link
Copy Markdown

In procrustes.align(..., reflection=False), np.dot(u[:, :nsv] * s, vh) returns the transposed rotation and overwrites s before ss = sum(s). On a 3D 90-degree rotation R, align returns 3 * R.T; on a 2D reflection, ss becomes 0.0 and align returns zeros.

Using a sign vector d for t = np.dot(vh.T * d, u.T) and ss = float(np.sum(s * d)) matches Schonemann (1966) and Umeyama (1991), with tests in tests/test_procrustes.py. Happy to clamp ss at 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).

@codecov-commenter

Copy link
Copy Markdown

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 ☂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants