Code Duplication    Length = 19-19 lines in 2 locations

tests/transforms/preprocessing/test_crop_pad.py 2 locations

@@ 116-134 (lines=19) @@
113
                f'Wrong shape for image: {key}',
114
            )
115
116
    def test_mask_only_crop(self):
117
        target_shape = 9, 18, 30
118
        transform = CropOrPad(target_shape, mask_name='label')
119
        mask = self.sample_subject['label'][DATA]
120
        mask *= 0
121
        mask[0, 4:6, 5:8, 3:7] = 1
122
        transformed = transform(self.sample_subject)
123
        shapes = []
124
        for key in transformed:
125
            result_shape = transformed[key].spatial_shape
126
            shapes.append(result_shape)
127
        set_shapes = set(shapes)
128
        message = f'Images have different shapes: {set_shapes}'
129
        assert len(set_shapes) == 1, message
130
        for key in transformed:
131
            result_shape = transformed[key].spatial_shape
132
            self.assertEqual(
133
                target_shape, result_shape,
134
                f'Wrong shape for image: {key}',
135
            )
136
137
    def test_center_mask(self):
@@ 95-113 (lines=19) @@
92
        with self.assertWarns(UserWarning):
93
            transform(self.sample_subject)
94
95
    def test_mask_only_pad(self):
96
        target_shape = 11, 22, 30
97
        transform = CropOrPad(target_shape, mask_name='label')
98
        mask = self.sample_subject['label'][DATA]
99
        mask *= 0
100
        mask[0, 4:6, 5:8, 3:7] = 1
101
        transformed = transform(self.sample_subject)
102
        shapes = []
103
        for key in transformed:
104
            result_shape = transformed[key].spatial_shape
105
            shapes.append(result_shape)
106
        set_shapes = set(shapes)
107
        message = f'Images have different shapes: {set_shapes}'
108
        assert len(set_shapes) == 1, message
109
        for key in transformed:
110
            result_shape = transformed[key].spatial_shape
111
            self.assertEqual(
112
                target_shape, result_shape,
113
                f'Wrong shape for image: {key}',
114
            )
115
116
    def test_mask_only_crop(self):