From 8354d12749e40a37ccd5a4311503eab132980b6a Mon Sep 17 00:00:00 2001 From: Fei Hu Date: Thu, 1 Aug 2019 22:43:24 -0700 Subject: [PATCH] Temporarily disable test_invalid_shapes in the graph mode --- .../image/distort_image_ops_test.py | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tensorflow_addons/image/distort_image_ops_test.py b/tensorflow_addons/image/distort_image_ops_test.py index 0a03f35495..b134991c22 100644 --- a/tensorflow_addons/image/distort_image_ops_test.py +++ b/tensorflow_addons/image/distort_image_ops_test.py @@ -21,13 +21,13 @@ import numpy as np import tensorflow as tf -from tensorflow_addons.image import distort_image_ops +from tensorflow.python.eager import context -# from tensorflow_addons.utils import test_utils +from tensorflow_addons.image import distort_image_ops +from tensorflow_addons.utils import test_utils -# TODO: #373 Get this to run in graph mode as well -# @test_utils.run_all_in_graph_and_eager_modes +@test_utils.run_all_in_graph_and_eager_modes class AdjustHueInYiqTest(tf.test.TestCase): def _adjust_hue_in_yiq_np(self, x_np, delta_h): """Rotate hue in YIQ space. @@ -101,11 +101,14 @@ def test_adjust_random_hue_in_yiq(self): y_tf = self._adjust_hue_in_yiq_tf(x_np, delta_h) self.assertAllClose(y_tf, y_np, rtol=2e-4, atol=1e-4) + # TODO: #373 Get this to run in graph mode as well def test_invalid_shapes(self): x_np = np.random.rand(2, 3) * 255. delta_h = np.random.rand() * 2.0 - 1.0 with self.assertRaises((tf.errors.InvalidArgumentError, ValueError)): self.evaluate(self._adjust_hue_in_yiq_tf(x_np, delta_h)) + if not context.executing_eagerly(): + self.skipTest("This test does not work in the graph mode yet.") x_np = np.random.rand(4, 2, 4) * 255. delta_h = np.random.rand() * 2.0 - 1.0 with self.assertRaisesOpError("input must have 3 channels " @@ -132,8 +135,7 @@ def test_random_hsv_in_yiq_unknown_shape(self): self.assertAllEqual(fn(image_tf), fn(image_tf)) -# TODO: #373 Get this to run in graph mode as well -# @test_utils.run_all_in_graph_and_eager_modes +@test_utils.run_all_in_graph_and_eager_modes class AdjustValueInYiqTest(tf.test.TestCase): def _adjust_value_in_yiq_np(self, x_np, scale): return x_np * scale @@ -180,11 +182,14 @@ def test_adjust_random_value_in_yiq(self): y_tf = self._adjust_value_in_yiq_tf(x_np, scale) self.assertAllClose(y_tf, y_np, rtol=2e-4, atol=1e-4) + # TODO: #373 Get this to run in graph mode as well def test_invalid_shapes(self): x_np = np.random.rand(2, 3) * 255. scale = np.random.rand() * 2.0 - 1.0 with self.assertRaises((tf.errors.InvalidArgumentError, ValueError)): self.evaluate(self._adjust_value_in_yiq_tf(x_np, scale)) + if not context.executing_eagerly(): + self.skipTest("This test does not work in the graph mode yet.") x_np = np.random.rand(4, 2, 4) * 255. scale = np.random.rand() * 2.0 - 1.0 with self.assertRaisesOpError("input must have 3 channels " @@ -192,8 +197,7 @@ def test_invalid_shapes(self): self.evaluate(self._adjust_value_in_yiq_tf(x_np, scale)) -# TODO: #373 Get this to run in graph mode as well -# @test_utils.run_all_in_graph_and_eager_modes +@test_utils.run_all_in_graph_and_eager_modes class AdjustSaturationInYiqTest(tf.test.TestCase): def _adjust_saturation_in_yiq_tf(self, x_np, scale): x = tf.constant(x_np) @@ -244,11 +248,14 @@ def test_adjust_random_saturation_in_yiq(self): y_tf = self._adjust_saturation_in_yiq_tf(x_np, scale) self.assertAllClose(y_tf, y_baseline, rtol=2e-4, atol=1e-4) + # TODO: #373 Get this to run in graph mode as well def test_invalid_shapes(self): x_np = np.random.rand(2, 3) * 255. scale = np.random.rand() * 2.0 - 1.0 with self.assertRaises((tf.errors.InvalidArgumentError, ValueError)): self.evaluate(self._adjust_saturation_in_yiq_tf(x_np, scale)) + if not context.executing_eagerly(): + self.skipTest("This test does not work in the graph mode yet.") x_np = np.random.rand(4, 2, 4) * 255. scale = np.random.rand() * 2.0 - 1.0 with self.assertRaisesOpError("input must have 3 channels "