Repository navigation
Conversation
Added support for stacked numpy arrays in baseposelist.py.
… error Added support for SE3 constructor with (N, 4, 4) NumPy array.
Add unit test for SE3 constructor with stacked array input.
taughz
left a comment
There was a problem hiding this comment.
I think there might be a regression here with check=False. I've pushed some testing changes to your branch. Happy to re-review.
|
@RoboX2020 Ping? |
The shape guard added with the stacked-array support rejected every array whose shape differed from the class's internal value shape when check=False. That broke accepted equivalent forms: Twist3 from a 4x4 SE(3)/se(3) matrix, Twist2 from a 3x3 SE(2)/se(2) matrix, and Quaternion from a non-4-vector array, all of which the class _import methods deliberately accept unchecked. Only reject when a matrix pose class (SE3, SO3, SE2, SO2) gets a 3D array whose per-matrix size is wrong: such an array can only be read as a stack, so the mismatch is never a valid pose, whatever check is. Single 2D arrays keep their historical check=False behavior.
|
Fixed - the shape guard was too broad. With |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Closes #236.
SE3(arr)with an(N, 4, 4)array raised "bad argument to constructor", and withcheck=Falseit returned a malformed object (length 1, but.Aof shape(N, 4, 4)).Changes:
BasePoseList.arghandler: anndarraywith shape(N, r, c), where(r, c)is the shape of one value of the class, is now taken as N values, the same asSE3(list(arr)). Each matrix still goes through the class's validity check whencheck=True. This covers the matrix classesSE3,SO3,SE2andSO2.check=False, single arrays keep their historical behavior; only a stacked 3D array whose per-matrix size is wrong is rejected, whatevercheckis.SE3error message now lists the accepted forms, and the constructor docstring documents the new form.Test:
test_constructor_stacked_arraycoversSE3andSO3from a stacked array with bothcheckvalues, the empty(0, 4, 4)case, rejection of invalid matrices withcheck=Trueand of a wrong-sized stack with either value. It fails onmasterand passes with this change.Run locally (Python 3.11):
pytest testsgives 348 passed, 3 skipped. black 23.10.0 is clean. Not run: the docs build and other Python versions.