MCPcopy Create free account
hub / github.com/SimpleITK/SimpleITK / test_deepcopy

Function test_deepcopy

Wrapping/Python/tests/sitkImageTests.py:54–75  ·  view source on GitHub ↗

Test the custom __deepcopy__ method

()

Source from the content-addressed store, hash-verified

52
53
54def test_deepcopy():
55 """Test the custom __deepcopy__ method"""
56 sz = [10, 10]
57 img = sitk.Image(sz, sitk.sitkFloat32)
58 img[1, 2] = 3.14
59 img.SetSpacing([1.2, 3.4])
60
61 img_dc = copy.deepcopy(img)
62 assert_image_equal(img, img_dc)
63
64 img_dc.SetOrigin([7, 8])
65 assert img.GetOrigin() != img_dc.GetOrigin()
66
67 img_dc.SetOrigin(img.GetOrigin())
68 img_dc[9, 9] = 1.234
69 assert sitk.Hash(img) != sitk.Hash(img_dc)
70
71 img_c = copy.copy(img)
72 assert_image_equal(img, img_c)
73
74 img_c.SetOrigin([7, 8])
75 assert img.GetOrigin() != img_c.GetOrigin()
76
77
78def test_get_item_metadata():

Callers

nothing calls this directly

Calls 5

SetSpacingMethod · 0.95
GetOriginMethod · 0.95
assert_image_equalFunction · 0.85
ImageMethod · 0.80
SetOriginMethod · 0.45

Tested by

no test coverage detected