Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
eigenpy
Commits
bfb26e47
Verified
Commit
bfb26e47
authored
Mar 18, 2020
by
Justin Carpentier
Browse files
test: test new sharedMemory feature
parent
0334425f
Changes
1
Hide whitespace changes
Inline
Side-by-side
unittest/python/test_return_by_ref.py
View file @
bfb26e47
import
return_by_ref
from
return_by_ref
import
Matrix
,
RowMatrix
,
Vector
from
return_by_ref
import
Matrix
,
RowMatrix
,
Vector
import
numpy
as
np
import
numpy
as
np
def
test
(
mat
):
def
test
_shared
(
mat
):
m_ref
=
mat
.
ref
()
m_ref
=
mat
.
ref
()
m_ref
.
fill
(
0
)
m_ref
.
fill
(
0
)
...
@@ -22,6 +23,27 @@ def test(mat):
...
@@ -22,6 +23,27 @@ def test(mat):
except
:
except
:
assert
True
assert
True
def
test_not_shared
(
mat
):
m_ref
=
mat
.
ref
()
m_ref
.
fill
(
100.
)
m_copy
=
mat
.
copy
()
assert
not
np
.
array_equal
(
m_ref
,
m_copy
)
m_const_ref
=
mat
.
const_ref
()
assert
np
.
array_equal
(
m_const_ref
,
m_copy
)
assert
not
np
.
array_equal
(
m_const_ref
,
m_ref
)
m_ref
.
fill
(
10.
)
assert
not
np
.
array_equal
(
m_ref
,
m_copy
)
assert
not
np
.
array_equal
(
m_const_ref
,
m_ref
)
try
:
m_const_ref
.
fill
(
2
)
assert
True
except
:
assert
False
rows
=
10
rows
=
10
cols
=
30
cols
=
30
...
@@ -29,6 +51,13 @@ mat = Matrix(rows,cols)
...
@@ -29,6 +51,13 @@ mat = Matrix(rows,cols)
row_mat
=
RowMatrix
(
rows
,
cols
)
row_mat
=
RowMatrix
(
rows
,
cols
)
vec
=
Vector
(
rows
,
1
)
vec
=
Vector
(
rows
,
1
)
test
(
mat
)
test_shared
(
mat
)
test
(
row_mat
)
test_shared
(
row_mat
)
test
(
vec
)
test_shared
(
vec
)
return_by_ref
.
sharedMemory
(
False
)
test_not_shared
(
mat
)
test_not_shared
(
row_mat
)
test_not_shared
(
vec
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment