(self, input_shape, init_params)
| 79 | assert_allclose(out_im, expected_array, type_test=False) |
| 80 | |
| 81 | def multi_inverse(self, input_shape, init_params): |
| 82 | input_data = np.arange(np.prod(input_shape)).reshape(*input_shape) + 1 |
| 83 | xform = self.Cropper(**init_params) |
| 84 | xform.set_random_state(1234) |
| 85 | out = xform(input_data) |
| 86 | if "num_samples" in init_params: |
| 87 | self.assertEqual(len(out), init_params["num_samples"]) |
| 88 | inv = xform.inverse(out) |
| 89 | self.assertIsInstance(inv, MetaTensor) |
| 90 | self.assertEqual(inv.applied_operations, []) |
| 91 | self.assertTrue("patch_index" not in inv.meta) |
| 92 | self.assertTupleEqual(inv.shape, input_shape) |
| 93 | inv_np = inv.numpy() |
| 94 | |
| 95 | # get list of all numbers that exist inside the crops |
| 96 | uniques = set() |
| 97 | for o in out: |
| 98 | uniques.update(set(o.flatten().tolist())) |
| 99 | |
| 100 | # make sure that |
| 101 | for i in uniques: |
| 102 | a = np.where(input_data == i) |
| 103 | b = np.where(inv_np == i) |
| 104 | self.assertTupleEqual(a, b) |
| 105 | # there should be as many zeros as elements missing from uniques |
| 106 | missing = input_data.size - len(uniques) |
| 107 | self.assertEqual((inv_np == 0).sum(), missing) |
| 108 | |
| 109 | def crop_test_pending_ops(self, input_param, input_shape, align_corners=False): |
| 110 | crop_fn = self.Cropper(**input_param) |
nothing calls this directly
no test coverage detected