Skip to content

Commit 73222bf

Browse files
authored
Accept a stacked (N, r, c) array as a sequence of poses
Added support for stacked numpy arrays in baseposelist.py.
1 parent 2de7801 commit 73222bf

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎spatialmath/baseposelist.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ def arghandler(
154154
155155
#. None, an identity value is created
156156
#. a numpy.ndarray of the appropriate shape and value which is valid for the subclass
157+
#. a stacked numpy.ndarray of shape (N, r, c), where (r, c) is the shape of one value
158+
of the subclass, which is a sequence of N values
157159
#. a list whose elements all meet the criteria above
158160
#. an instance of the subclass
159161
#. a list whose elements are all singelton instances of the subclass
@@ -187,6 +189,19 @@ def arghandler(
187189
elif isinstance(arg, np.ndarray):
188190
# it's a numpy array
189191

192+
shape = tuple(self.shape)
193+
if len(shape) == 2 and arg.ndim == 3 and arg.shape[1:] == shape:
194+
# a stacked (N, r, c) array is a sequence of N values
195+
values = [self._import(x, check=check) for x in arg]
196+
if any(x is None for x in values):
197+
return False
198+
self.data = values
199+
return True
200+
201+
if not check and arg.shape != shape:
202+
# check=False skips the value checks, but not the shape check
203+
return False
204+
190205
x = self._import(arg, check=check)
191206
if x is not None:
192207
self.data = [x]

0 commit comments

Comments
 (0)