8000 Unit testing to amke sure pass by value is invoked on CopyFrom · george0407/spatialmath-python@218201e · GitHub
[go: up one dir, main page]

Skip to content

Commit 218201e

Browse files
committed
Unit testing to amke sure pass by value is invoked on CopyFrom
1 parent d90607b commit 218201e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/test_pose3d.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,21 @@ def test_properties(self):
888888
nt.assert_equal(R.N, 3)
889889
nt.assert_equal(R.shape, (4, 4))
890890

891+
# Testing the CopyFrom function
892+
mutable_array = np.eye(4)
893+
pass_by_ref = SE3(mutable_array)
894+
pass_by_val = SE3.CopyFrom(mutable_array)
895+
mutable_array[0, 3] = 5.0
896+
nt.assert_allclose(pass_by_val.data[0], np.eye(4))
897+
nt.assert_allclose(pass_by_ref.data[0], mutable_array)
898+
nt.assert_raises(
899+
AssertionError,
900+
nt.assert_allclose,
901+
pass_by_val.data[0],
902+
pass_by_ref.data[0]
903+
)
904+
905+
891906
def test_arith(self):
892907
T = SE3(1, 2, 3)
893908

0 commit comments

Comments
 (0)
0