Repository navigation
Commit 41e0a4d
test+fix: direct tests for e2h/h2e, h2e rejects <2 rows, document contract (#240)
`e2h` and `h2e` had a single assertion each (N-vector input only). The
matrix path and `h2e`'s per-column scaling were only exercised
indirectly through the pose tests, and the shape contract for 2D input
was undocumented.
**Tests** (`tests/base/test_transformsNd.py`)
- vector input as list, tuple, 1D array and column vector
- matrix input for both functions
- `h2e` scaling by each column's own last element
- `h2e(e2h(x))` and `e2h(h2e(x))` round trips
- `ValueError` for bad types
- a characterization test pinning that a `(1,N)` array is a matrix of N
1-vectors, not a row vector. This documents current behavior rather than
endorsing it, so any change to it is deliberate.
**Behavior change (small)**
- `h2e` now raises `ValueError` for input with fewer than two rows (a
`(1,N)` array, a length-1 vector, or a scalar). Previously it returned
an empty `(0,N)` array, which is never useful: a homogeneous point has
at least two elements. Checked callers in MVTB (`Camera.py`,
`ImageReshape.py`); both pass 3-row arrays.
- `e2h` is unchanged.
**Docstrings** (`spatialmath/base/transformsNd.py`)
- Both functions state the contract up front: each *column* is a point,
rows are never points, with explicit shapes and a note on how to convert
a row vector (pass its transpose).
- `:raises:` entries added; `e2h`'s `:seealso:` pointed at itself, now
`h2e`.
Rank-0 and rank-3 rejection is covered by #239 (`isvector`) and is
deliberately not duplicated here; this PR is independent of it.
Full suite: 355 passed, 3 skipped.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>1 parent b638e40 commit 41e0a4d
2 files changed
Lines changed: 88 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
771 | 771 | | |
772 | 772 | | |
773 | 773 | | |
774 | | - | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
775 | 777 | | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
780 | 783 | | |
781 | 784 | | |
782 | 785 | | |
| |||
788 | 791 | | |
789 | 792 | | |
790 | 793 | | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
791 | 798 | | |
792 | | - | |
| 799 | + | |
793 | 800 | | |
794 | 801 | | |
795 | 802 | | |
| 803 | + | |
| 804 | + | |
796 | 805 | | |
797 | 806 | | |
798 | 807 | | |
799 | 808 | | |
800 | 809 | | |
| 810 | + | |
| 811 | + | |
801 | 812 | | |
802 | 813 | | |
803 | 814 | | |
| |||
811 | 822 | | |
812 | 823 | | |
813 | 824 | | |
814 | | - | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
815 | 829 | | |
816 | | - | |
817 | | - | |
818 | | - | |
819 | | - | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
820 | 834 | | |
821 | 835 | | |
822 | 836 | | |
| |||
827 | 841 | | |
828 | 842 | | |
829 | 843 | | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
830 | 848 | | |
831 | | - | |
| 849 | + | |
832 | 850 | | |
833 | 851 | | |
834 | 852 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
264 | 322 | | |
265 | 323 | | |
266 | 324 | | |
| |||
0 commit comments