File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ ENDIF()
4040ADD_PYTHON_UNIT_TEST("py-matrix" "unittest/python/test_matrix.py" "unittest" )
4141ADD_PYTHON_UNIT_TEST("py-geometry" "unittest/python/test_geometry.py" "unittest" )
4242ADD_PYTHON_UNIT_TEST("py-complex" "unittest/python/test_complex.py" "unittest" )
43+ ADD_PYTHON_UNIT_TEST("py-return-by-ref" "unittest/python/test_return_by_ref.py" "unittest" )
4344
4445ADD_PYTHON_UNIT_TEST("py-switch" "unittest/python/test_switch.py" "python/eigenpy" )
4546SET_TESTS_PROPERTIES ("py-switch" PROPERTIES DEPENDS ${PYWRAP} )
Original file line number Diff line number Diff line change 1+ from return_by_ref import Matrix , RowMatrix , Vector
2+ import numpy as np
3+
4+ def test (mat ):
5+
6+ m_ref = mat .ref ()
7+ m_ref .fill (0 )
8+ m_copy = mat .copy ()
9+ assert np .array_equal (m_ref ,m_copy )
10+
11+ m_const_ref = mat .const_ref ()
12+ assert np .array_equal (m_const_ref ,m_copy )
13+ assert np .array_equal (m_const_ref ,m_ref )
14+
15+ m_ref .fill (1 )
16+ assert not np .array_equal (m_ref ,m_copy )
17+ assert np .array_equal (m_const_ref ,m_ref )
18+
19+ try :
20+ m_const_ref .fill (2 )
21+ assert False
22+ except :
23+ assert True
24+
25+ rows = 10
26+ cols = 30
27+
28+ mat = Matrix (rows ,cols )
29+ row_mat = RowMatrix (rows ,cols )
30+ vec = Vector (rows ,1 )
31+
32+ test (mat )
33+ test (row_mat )
34+ test (vec )
You can’t perform that action at this time.
0 commit comments