Skip to content

Commit c104124

Browse files
committed
Temporarily disable test_invalid_shapes in the graph mode
1 parent 230a7fc commit c104124

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

tensorflow_addons/image/distort_image_ops_test.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
import numpy as np
2222

2323
import tensorflow as tf
24-
from tensorflow_addons.image import distort_image_ops
24+
from tensorflow.python.eager import context
2525

26-
# from tensorflow_addons.utils import test_utils
26+
from tensorflow_addons.image import distort_image_ops
27+
from tensorflow_addons.utils import test_utils
2728

2829

29-
# TODO: #373 Get this to run in graph mode as well
30-
# @test_utils.run_all_in_graph_and_eager_modes
30+
@test_utils.run_all_in_graph_and_eager_modes
3131
class AdjustHueInYiqTest(tf.test.TestCase):
3232
def _adjust_hue_in_yiq_np(self, x_np, delta_h):
3333
"""Rotate hue in YIQ space.
@@ -101,11 +101,14 @@ def test_adjust_random_hue_in_yiq(self):
101101
y_tf = self._adjust_hue_in_yiq_tf(x_np, delta_h)
102102
self.assertAllClose(y_tf, y_np, rtol=2e-4, atol=1e-4)
103103

104+
# TODO: #373 Get this to run in graph mode as well
104105
def test_invalid_shapes(self):
105106
x_np = np.random.rand(2, 3) * 255.
106107
delta_h = np.random.rand() * 2.0 - 1.0
107108
with self.assertRaises((tf.errors.InvalidArgumentError, ValueError)):
108109
self.evaluate(self._adjust_hue_in_yiq_tf(x_np, delta_h))
110+
if not context.executing_eagerly():
111+
return
109112
x_np = np.random.rand(4, 2, 4) * 255.
110113
delta_h = np.random.rand() * 2.0 - 1.0
111114
with self.assertRaisesOpError("input must have 3 channels "
@@ -132,8 +135,7 @@ def test_random_hsv_in_yiq_unknown_shape(self):
132135
self.assertAllEqual(fn(image_tf), fn(image_tf))
133136

134137

135-
# TODO: #373 Get this to run in graph mode as well
136-
# @test_utils.run_all_in_graph_and_eager_modes
138+
@test_utils.run_all_in_graph_and_eager_modes
137139
class AdjustValueInYiqTest(tf.test.TestCase):
138140
def _adjust_value_in_yiq_np(self, x_np, scale):
139141
return x_np * scale
@@ -180,20 +182,22 @@ def test_adjust_random_value_in_yiq(self):
180182
y_tf = self._adjust_value_in_yiq_tf(x_np, scale)
181183
self.assertAllClose(y_tf, y_np, rtol=2e-4, atol=1e-4)
182184

185+
# TODO: #373 Get this to run in graph mode as well
183186
def test_invalid_shapes(self):
184187
x_np = np.random.rand(2, 3) * 255.
185188
scale = np.random.rand() * 2.0 - 1.0
186189
with self.assertRaises((tf.errors.InvalidArgumentError, ValueError)):
187190
self.evaluate(self._adjust_value_in_yiq_tf(x_np, scale))
191+
if not context.executing_eagerly():
192+
return
188193
x_np = np.random.rand(4, 2, 4) * 255.
189194
scale = np.random.rand() * 2.0 - 1.0
190195
with self.assertRaisesOpError("input must have 3 channels "
191196
"but instead has 4 channels"):
192197
self.evaluate(self._adjust_value_in_yiq_tf(x_np, scale))
193198

194199

195-
# TODO: #373 Get this to run in graph mode as well
196-
# @test_utils.run_all_in_graph_and_eager_modes
200+
@test_utils.run_all_in_graph_and_eager_modes
197201
class AdjustSaturationInYiqTest(tf.test.TestCase):
198202
def _adjust_saturation_in_yiq_tf(self, x_np, scale):
199203
x = tf.constant(x_np)
@@ -244,11 +248,14 @@ def test_adjust_random_saturation_in_yiq(self):
244248
y_tf = self._adjust_saturation_in_yiq_tf(x_np, scale)
245249
self.assertAllClose(y_tf, y_baseline, rtol=2e-4, atol=1e-4)
246250

251+
# TODO: #373 Get this to run in graph mode as well
247252
def test_invalid_shapes(self):
248253
x_np = np.random.rand(2, 3) * 255.
249254
scale = np.random.rand() * 2.0 - 1.0
250255
with self.assertRaises((tf.errors.InvalidArgumentError, ValueError)):
251256
self.evaluate(self._adjust_saturation_in_yiq_tf(x_np, scale))
257+
if not context.executing_eagerly():
258+
return
252259
x_np = np.random.rand(4, 2, 4) * 255.
253260
scale = np.random.rand() * 2.0 - 1.0
254261
with self.assertRaisesOpError("input must have 3 channels "

0 commit comments

Comments
 (0)