def test_merge_preset(self, image, image_high, image_low): """Tests that the merge function merges as expected.""" image = tf.expand_dims(tf.expand_dims(image, axis=-1), axis=0) image_high = tf.expand_dims(tf.expand_dims(image_high, axis=-1), axis=0) image_low = tf.expand_dims(tf.expand_dims(image_low, axis=-1), axis=0) self.assertAllClose(image, pyramid.merge((image_high, image_low)))
def test_split_merge_random(self, num_levels): """Tests that splitting and merging back can reproduce the input.""" tensor_shape = np.random.randint(1, 5, size=4).tolist() image_random = np.random.uniform(size=tensor_shape) split = pyramid.split(image_random, num_levels=num_levels) merge = pyramid.merge(split) self.assertAllClose(image_random, merge)
def test_merge_exception_raised(self, error_msg, *shape): """Tests that the shape exceptions are properly raised.""" merge = lambda l0, l1: pyramid.merge((l0, l1)) self.assert_exception_is_raised(merge, error_msg, shape)
def test_merge_exception_not_raised(self, *shape): """Tests that the shape exceptions are not raised.""" merge = lambda l0, l1: pyramid.merge((l0, l1)) self.assert_exception_is_not_raised(merge, shape)