squeeze extra dims for numpy vectors

release/4.3a0
Duy-Nguyen Ta 2016-11-30 05:52:47 -05:00
parent e37ce8eccb
commit 6297b55f28
1 changed files with 3 additions and 3 deletions

View File

@ -6,9 +6,9 @@ def Vector(*args):
Convenient function to create numpy vector to use with gtsam cython wrapper Convenient function to create numpy vector to use with gtsam cython wrapper
Usage: Vector(1), Vector(1,2,3), Vector(3,2,4) Usage: Vector(1), Vector(1,2,3), Vector(3,2,4)
""" """
ret = np.asarray(args, dtype='float') ret = np.squeeze(np.asarray(args, dtype='float'))
while ret.ndim >= 2: if ret.ndim == 0:
ret = ret[0, :] ret = np.expand_dims(ret, axis=0)
return ret return ret