Repository navigation
Commit 4477d43
authored
test: add regression coverage for trlog near-identity division (#208)
## Summary
- `trlog`'s general-case branch (SO(3)) divides by `sin(theta)`,
computed from `trace(R)` via `acos`. The only existing coverage
(`test_trlog`) used `R = np.eye(3)` exactly — never a numerically
near-identity matrix as produced by real computation.
- That gap is exactly what #63 reported: a near-identity `R` reaching
the general case and dividing by (effectively) zero.
- Confirmed against the pre-`a9fc08a` code (*"rework code to be more
robust to nearly identity rotation matrix"*) that `rotx(1e-9)` — not
caught by `iseye()`, and not exactly `np.eye(3)` — raises
`FloatingPointError: divide by zero encountered in divide` there under
strict numpy error settings. Current code's `st == 0` guard (added in
`a9fc08a`) plus the `acos` domain clamp (added in `5d1044a`) handle it
cleanly.
- Also adds a case at `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
- [x] `pytest tests/base/test_transforms3d.py -k trlog -v` — both tests
pass
- [x] `pytest tests/base/test_transforms3d.py` — full file, 30 passed
- [x] Verified the new case reproduces a real `FloatingPointError`
against the pre-`a9fc08a` code path1 parent d0adcdf commit 4477d43
1 file changed
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
319 | 319 | | |
320 | 320 | | |
321 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
322 | 350 | | |
323 | 351 | | |
324 | 352 | | |
| |||
0 commit comments