Skip to content

Commit 67ebc01

Browse files
RoboX2020Instinct Agent
authored andcommitted
Keep check=False lenient; reject only wrong-size stacked arrays
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.
1 parent 1fb1b5d commit 67ebc01

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎spatialmath/baseposelist.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,18 +190,19 @@ def arghandler(
190190
# it's a numpy array
191191

192192
shape = tuple(self.shape)
193-
if len(shape) == 2 and arg.ndim == 3 and arg.shape[1:] == shape:
193+
if len(shape) == 2 and arg.ndim == 3:
194+
# a 3D array passed to a matrix pose class is a stack
195+
if arg.shape[1:] != shape:
196+
# a stack of matrices of the wrong size is rejected,
197+
# whatever the value of check
198+
return False
194199
# a stacked (N, r, c) array is a sequence of N values
195200
values = [self._import(x, check=check) for x in arg]
196201
if any(x is None for x in values):
197202
return False
198203
self.data = values
199204
return True
200205

201-
if not check and arg.shape != shape:
202-
# check=False skips the value checks, but not the shape check
203-
return False
204-
205206
x = self._import(arg, check=check)
206207
if x is not None:
207208
self.data = [x]

0 commit comments

Comments
 (0)