Repository: Project-MONAI/MONAI
File: tests/test_deepgrow_transforms.py (Python)

Code before:
]

RESULT = np.zeros((10, 20, 20))
RESULT[4:8, 4:8, 4:8] = np.array(
    [
        [[1.0, 1.0, 2.0, 2.0], [1.0, 1.0, 2.0, 2.0], [3.0, 3.0, 4.0, 4.0], [3.0, 3.0, 4.0, 4.0]],
        [[1.0, 1.0, 2.0, 2.0], [1.0, 1.0, 2.0, 2.0], [3.0, 3.0, 4.0, 4.0], [3.0, 3.0, 4.0, 4.0]],
        [[5.0, 5.0, 6.0, 6.0], [5.0, 5.0, 6.0, 6.0], [7.0, 7.0, 8.0, 8.0], [7.0, 7.0, 8.0, 8.0]],
        [[5.0, 5.0, 6.0, 6.0], [5.0, 5.0, 6.0, 6.0], [7.0, 7.0, 8.0, 8.0], [7.0, 7.0, 8.0, 8.0]],
    ]
)

RESTORE_LABEL_TEST_CASE_2 = [{"keys": ["pred"], "ref_image": "image", "mode": "nearest"}, DATA_11, RESULT]

RESTORE_LABEL_TEST_CASE_3_RESULT = np.zeros((10, 20, 20))
for layer in range(5):
    RESTORE_LABEL_TEST_CASE_3_RESULT[layer, 0:10, 0:10] = 1
    RESTORE_LABEL_TEST_CASE_3_RESULT[layer, 0:10, 10:20] = 2
    RESTORE_LABEL_TEST_CASE_3_RESULT[layer, 10:20, 0:10] = 3
    RESTORE_LABEL_TEST_CASE_3_RESULT[layer, 10:20, 10:20] = 4

for layer in range(5, 10):
    RESTORE_LABEL_TEST_CASE_3_RESULT[layer, 0:10, 0:10] = 5
    RESTORE_LABEL_TEST_CASE_3_RESULT[layer, 0:10, 10:20] = 6
    RESTORE_LABEL_TEST_CASE_3_RESULT[layer, 10:20, 0:10] = 7
    RESTORE_LABEL_TEST_CASE_3_RESULT[layer, 10:20, 10:20] = 8

RESTORE_LABEL_TEST_CASE_3 = [
    {"keys": ["pred"], "ref_image": "image", "mode": "nearest", "restore_cropping": False},
    DATA_11,
    RESTORE_LABEL_TEST_CASE_3_RESULT,
]

RESTORE_LABEL_TEST_CASE_4 = [
    {
        "keys": ["pred"],
        "ref_image": "image",
        "mode": "nearest",
        "restore_resizing": False,
        "restore_cropping": False,
        "restore_spacing": False,
        "restore_slicing": False,
    },
    DATA_11,
    np.array([[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]]),
]

FETCH_2D_SLICE_TEST_CASE_1 = [
    {"keys": ["image"], "guidance": "guidance"},
    DATA_12,
    np.array([[9, 10, 11], [12, 13, 14], [15, 16, 17]]),

Review comment (suggestion):
```suggestion
RESTORE_LABEL_TEST_CASE_3_RESULT[:5, 0:10, 0:10] = 1
RESTORE_LABEL_TEST_CASE_3_RESULT[:5, 0:10, 10:20] = 2
RESTORE_LABEL_TEST_CASE_3_RESULT[:5, 10:20, 0:10] = 3
RESTORE_LABEL_TEST_CASE_3_RESULT[:5, 10:20, 10:20] = 4
RESTORE_LABEL_TEST_CASE_3_RESULT[5:10, 0:10, 0:10] = 5
RESTORE_LABEL_TEST_CASE_3_RESULT[5:10, 0:10, 10:20] = 6
RESTORE_LABEL_TEST_CASE_3_RESULT[5:10, 10:20, 0:10] = 7
RESTORE_LABEL_TEST_CASE_3_RESULT[5:10, 10:20, 10:20] = 8
```

Code after:
            ]
        ]
    ),
]

RESIZE_GUIDANCE_TEST_CASE_1 = [
    {"ref_image": "image", "guidance": "guidance"},
    DATA_9,
    [[[3, 5, 7], [4, 5, 7]], [[4, 5, 8]]],
]

RESTORE_LABEL_TEST_CASE_1 = [
    {"keys": ["pred"], "ref_image": "image", "mode": "nearest"},
    DATA_10,
    np.array([[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]),
]

RESULT = np.zeros((10, 20, 20))
RESULT[4:8, 4:8, 4:8] = np.array(
    [
        [[1.0, 1.0, 2.0, 2.0], [1.0, 1.0, 2.0, 2.0], [3.0, 3.0, 4.0, 4.0], [3.0, 3.0, 4.0, 4.0]],
        [[1.0, 1.0, 2.0, 2.0], [1.0, 1.0, 2.0, 2.0], [3.0, 3.0, 4.0, 4.0], [3.0, 3.0, 4.0, 4.0]],
        [[5.0, 5.0, 6.0, 6.0], [5.0, 5.0, 6.0, 6.0], [7.0, 7.0, 8.0, 8.0], [7.0, 7.0, 8.0, 8.0]],
        [[5.0, 5.0, 6.0, 6.0], [5.0, 5.0, 6.0, 6.0], [7.0, 7.0, 8.0, 8.0], [7.0, 7.0, 8.0, 8.0]],
    ]
)

RESTORE_LABEL_TEST_CASE_2 = [{"keys": ["pred"], "ref_image": "image", "mode": "nearest"}, DATA_11, RESULT]

RESTORE_LABEL_TEST_CASE_3_RESULT = np.zeros((10, 20, 20))
RESTORE_LABEL_TEST_CASE_3_RESULT[:5, 0:10, 0:10] = 1
RESTORE_LABEL_TEST_CASE_3_RESULT[:5, 0:10, 10:20] = 2
RESTORE_LABEL_TEST_CASE_3_RESULT[:5, 10:20, 0:10] = 3
RESTORE_LABEL_TEST_CASE_3_RESULT[:5, 10:20, 10:20] = 4
RESTORE_LABEL_TEST_CASE_3_RESULT[5:10, 0:10, 0:10] = 5
RESTORE_LABEL_TEST_CASE_3_RESULT[5:10, 0:10, 10:20] = 6
RESTORE_LABEL_TEST_CASE_3_RESULT[5:10, 10:20, 0:10] = 7
RESTORE_LABEL_TEST_CASE_3_RESULT[5:10, 10:20, 10:20] = 8

RESTORE_LABEL_TEST_CASE_3 = [
    {"keys": ["pred"], "ref_image": "image", "mode": "nearest", "restore_cropping": False},
    DATA_11,
    RESTORE_LABEL_TEST_CASE_3_RESULT,
]

RESTORE_LABEL_TEST_CASE_4_RESULT = np.zeros((4, 8, 8))
RESTORE_LABEL_TEST_CASE_4_RESULT[1, 2:6, 2:6] = np.array(
    [[10.0, 10.0, 20.0, 20.0], [10.0, 10.0, 20.0, 20.0], [30.0, 30.0, 40.0, 40.0], [30.0, 30.0, 40.0, 40.0]]
)
RESTORE_LABEL_TEST_CASE_4_RESULT[2, 2:6, 2:6] = np.array(
    [[50.0, 50.0, 60.0, 60.0], [50.0, 50.0, 60.0, 60.0], [70.0, 70.0, 80.0, 80.0], [70.0, 70.0, 80.0, 80.0]]