Skip to content

Commit 28d585b

Browse files
committed
test: add test on switch between np.array and np.matrix
1 parent d6539ff commit 28d585b

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

unittest/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2016-2018 CNRS
2+
# Copyright (c) 2016-2018 CNRS INRIA
33
#
44
# This file is part of eigenpy
55
# eigenpy is free software: you can redistribute it
@@ -46,3 +46,4 @@ ENDIF()
4646

4747
ADD_PYTHON_UNIT_TEST("py-matrix" "unittest/python/test_matrix.py" "unittest")
4848
ADD_PYTHON_UNIT_TEST("py-geometry" "unittest/python/test_geometry.py" "unittest")
49+
ADD_PYTHON_UNIT_TEST("py-switch" "unittest/python/test_switch.py" "unittest")

unittest/python/test_switch.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from __future__ import print_function
2+
3+
import eigenpy
4+
import numpy as np
5+
6+
quat = eigenpy.Quaternion()
7+
# By default, we convert as numpy.matrix
8+
coeffs_vector = quat.coeffs()
9+
print(type(coeffs_vector))
10+
11+
assert isinstance(coeffs_vector,np.matrixlib.defmatrix.matrix)
12+
13+
# Switch to numpy.array
14+
eigenpy.switchToNumpyArray()
15+
coeffs_array = quat.coeffs()
16+
print(type(coeffs_array))
17+
18+
assert isinstance(coeffs_vector,np.ndarray)

0 commit comments

Comments
 (0)