code: def test_idw_shape(self):
      # 3D
      test_input = np.zeros((2, 8, 8, 8, 2))
      test_input[0, 0, 0, 0, 0] = 1.0
      test_input = tf.constant(test_input)
      test_coords = tf.ones((1, 5, 5, 5, 3)) * 0.1
      out = ResamplerLayer("IDW")(test_input, test_coords)
      with self.cached_session() as sess:
          out_value = sess.run(out)
          self.assertTrue(
              np.all(
                  np.isclose(
                      out_value[0, ..., 0],
                      1.0 / (1.0 + 9.0 / 83 + 9.0 / 163 + 3.0 / 243),
                      atol=1e-5,
                  )
              )
          )
          self.assertTrue(np.all(out_value[1, ...] == 0))
          self.assertEqual(out_value.shape, (2, 5, 5, 5, 2))
  
      # 2D
      test_input = np.zeros((2, 8, 8, 2))
      test_input[0, 0, 0, 0] = 1.0
      test_input = tf.constant(test_input)
      test_coords = tf.ones((1, 5, 5, 2)) * 0.1
      out = ResamplerLayer("IDW")(test_input, test_coords)
      with self.cached_session() as sess:
          out_value = sess.run(out)
          self.assertTrue(np.all(out_value[1, ...] == 0))
          self.assertTrue(
              np.all(
                  np.isclose(
                      out_value[0, ..., 0],
                      1.0 / (2.0 / 41.0 + 1.0 / 81.0 + 1.0),
                      atol=1e-5,
                  )
              )
          )
          self.assertEqual(out_value.shape, (2, 5, 5, 2))
  
      # 1D
      test_input = np.zeros((2, 8, 2))
      test_input[0, 0, 0] = 1.0
      test_input = tf.constant(test_input)
      test_coords = tf.ones((1, 5, 1)) * 0.1
      out = ResamplerLayer("IDW")(test_input, test_coords)
      with self.cached_session() as sess:
          out_value = sess.run(out)
          self.assertTrue(np.all(out_value[1, ...] == 0))
          self.assertTrue(
              np.all(
                  np.isclose(
                      out_value[0, ..., 0],
                      100.0 / (100.0 + 1 / 0.81),
                      atol=1e-5,
                  )
              )
          )
          self.assertEqual(out_value.shape, (2, 5, 2))
  
file_path: NiftyNet/tests/resampler_batch_test.py
imports: from __future__ import absolute_import, print_function, division
  import numpy
  import tensorflow
  from niftynet.layer.resampler import ResamplerLayer
  from tests.niftynet_testcase import NiftyNetTestCase
label_desc: Use image node_id 6 for calling the ResamplerTest obj's underlying member method code with example usage: obj.test_idw_shape() without return types