| 62 | assert_allclose(result["img_1"], torch.tensor([[1, 2], [2, 3]], device=device)) |
| 63 | |
| 64 | def test_array_values(self): |
| 65 | input_data = {"img": [[0, 1], [1, 2]], "seg": [[0, 1], [1, 2]]} |
| 66 | result = CopyItemsd(keys="img", times=1, names="img_1")(input_data) |
| 67 | self.assertTrue("img_1" in result) |
| 68 | result["img_1"][0][0] += 1 |
| 69 | np.testing.assert_allclose(result["img"], [[0, 1], [1, 2]]) |
| 70 | np.testing.assert_allclose(result["img_1"], [[1, 1], [1, 2]]) |
| 71 | |
| 72 | def test_graph_tensor_values(self): |
| 73 | device = torch.device("cuda:0") if torch.cuda.is_available() else torch.device("cpu:0") |