(
self,
out: torch.Tensor,
orig: torch.Tensor,
*,
shape: bool = True,
vals: bool = True,
ids: bool = True,
device: str | torch.device | None = None,
meta: bool = True,
check_ids: bool = True,
**kwargs,
)
| 78 | self.assertEqual(meta_a, meta_b) |
| 79 | |
| 80 | def check( |
| 81 | self, |
| 82 | out: torch.Tensor, |
| 83 | orig: torch.Tensor, |
| 84 | *, |
| 85 | shape: bool = True, |
| 86 | vals: bool = True, |
| 87 | ids: bool = True, |
| 88 | device: str | torch.device | None = None, |
| 89 | meta: bool = True, |
| 90 | check_ids: bool = True, |
| 91 | **kwargs, |
| 92 | ): |
| 93 | if device is None: |
| 94 | device = orig.device |
| 95 | |
| 96 | # check the image |
| 97 | self.assertIsInstance(out, type(orig)) |
| 98 | if shape: |
| 99 | assert_allclose(torch.as_tensor(out.shape), torch.as_tensor(orig.shape)) |
| 100 | if vals: |
| 101 | assert_allclose(out, orig, **kwargs) |
| 102 | if check_ids: |
| 103 | self.check_ids(out, orig, ids) |
| 104 | self.assertTrue(str(device) in str(out.device)) |
| 105 | |
| 106 | # check meta and affine are equal and affine is on correct device |
| 107 | if isinstance(orig, MetaTensor) and isinstance(out, MetaTensor) and meta: |
| 108 | self.check_meta(orig, out) |
| 109 | if check_ids: |
| 110 | self.check_ids(out.meta, orig.meta, ids) |
| 111 | |
| 112 | @parameterized.expand(TESTS) |
| 113 | def test_as_tensor(self, device, dtype): |
no test coverage detected