8000 getmatrix has dtype arg · suddrey-qut/spatialmath-python@3cd17f6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3cd17f6

Browse files
committed
getmatrix has dtype arg
1 parent 868a8f9 commit 3cd17f6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

spatialmath/base/argcheck.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def ismatrix(m, shape):
113113
return False
114114
return True
115115

116-
def getmatrix(m, shape):
116+
def getmatrix(m, shape, dtype=np.float64):
117117
r"""
118118
Convert argument to 2D array
119119
@@ -159,13 +159,13 @@ def getmatrix(m, shape):
159159
mshape = m.shape
160160

161161
if (shape[0] is None or shape[0] == mshape[0]) and (shape[1] is None or shape[1] == mshape[1]):
162-
return m
162+
return np.array(m, dtype=dtype)
163163
else:
164164
raise ValueError(f"expecting {shape} but got {mshape}")
165165

166166
elif isvector(m):
167167
# passed a 1D array
168-
m = getvector(m)
168+
m = getvector(m, dtype=dtype)
169169
if shape[0] is not None and shape[1] is not None:
170170
if len(m) == np.prod(shape):
171171
return m.reshape(shape)

0 commit comments

Comments
 (0)
0