test: add regression coverage for trlog near-identity division - #208
Open
petercorke wants to merge 1 commit into
Open
test: add regression coverage for trlog near-identity division#208petercorke wants to merge 1 commit into
petercorke wants to merge 1 commit into
Conversation
trlog's general-case branch divides by sin(theta), computed from trace(R) via acos. The only existing test used R = np.eye(3) exactly, never a numerically near-identity matrix as produced by real computation -- the case rai-opensource#63 (unmerged) reported hitting a divide-by-zero on. Confirmed against the pre-a9fc08a code (rework code to be more robust to nearly identity rotation matrix) that this exact input raised FloatingPointError there; current code's crisp `st == 0` guard handles it cleanly.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
trlog's general-case branch (SO(3)) divides bysin(theta), computed fromtrace(R)viaacos. The only existing coverage (test_trlog) usedR = np.eye(3)exactly — never a numerically near-identity matrix as produced by real computation.Rreaching the general case and dividing by (effectively) zero.a9fc08acode ("rework code to be more robust to nearly identity rotation matrix") thatrotx(1e-9)— not caught byiseye(), and not exactlynp.eye(3)— raisesFloatingPointError: divide by zero encountered in dividethere under strict numpy error settings. Current code'sst == 0guard (added ina9fc08a) plus theacosdomain clamp (added in5d1044a) handle it cleanly.theta=1e-7(small but not clamped) to confirm the general-case formula stays numerically accurate rather than needing a coarse fuzzy-tolerance fallback.Test plan
pytest tests/base/test_transforms3d.py -k trlog -v— both tests passpytest tests/base/test_transforms3d.py— full file, 30 passedFloatingPointErroragainst the pre-a9fc08acode path