Repository navigation
Commit 9295833
authored
deprecate: UnitQuaternion.interp1's shortest parameter is a no-op (#209)
## Summary
- Found while reviewing #193: `UnitQuaternion.interp1()`'s `shortest`
flag can never change its result. Every `UnitQuaternion` has a
non-negative scalar part by construction (`qunit()`'s own docstring:
"Scalar part is always positive"), confirmed empirically — 2000 random
`Rx*Ry*Rz` compositions, plus explicit `UnitQuaternion([-1,0,0,0])`
construction, all canonicalize to non-negative scalar part.
- `interp1` always interpolates *from* the identity quaternion
`[1,0,0,0]`. The dot product of identity with any unit quaternion is
just that quaternion's own scalar part — always non-negative — so the
`if dot < 0` branch `shortest` exists to trigger can never fire.
- This is specific to `interp1`; `.interp()` (the two-quaternion form)
is unaffected — there, `dot(q1, q2)` genuinely can go negative even when
both operands individually have non-negative scalar parts, since neither
operand is pinned to identity.
- Drops the dead branch, warns with `DeprecationWarning` when
`shortest=True` is passed, documents why in a docstring `.. note::`, and
pins the no-op behavior with a regression test (identical results for
`True`/`False` across several `s` values, warns only when `True`, silent
on the default).
## Test plan
- [x] `pytest tests/test_quaternion.py -v` — 37 passed, warning fires
exactly 6 times (once per `shortest=True` call in the new test)
- [x] `pytest tests/` — full suite, 343 passed, no regressions
- [x] Grepped the codebase and docs for other `interp1(...,
shortest=...)` callers — none found1 parent a624b59 commit 9295833
2 files changed
Lines changed: 51 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
2073 | 2074 | | |
2074 | 2075 | | |
2075 | 2076 | | |
2076 | | - | |
| 2077 | + | |
2077 | 2078 | | |
2078 | 2079 | | |
2079 | 2080 | | |
| |||
2104 | 2105 | | |
2105 | 2106 | | |
2106 | 2107 | | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
2107 | 2122 | | |
2108 | 2123 | | |
2109 | 2124 | | |
2110 | 2125 | | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
2111 | 2134 | | |
2112 | 2135 | | |
2113 | 2136 | | |
2114 | 2137 | | |
2115 | 2138 | | |
2116 | 2139 | | |
2117 | | - | |
2118 | | - | |
2119 | | - | |
| 2140 | + | |
2120 | 2141 | | |
2121 | 2142 | | |
2122 | 2143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
783 | 784 | | |
784 | 785 | | |
785 | 786 | | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
786 | 812 | | |
787 | 813 | | |
788 | 814 | | |
| |||
0 commit comments