Skip to content

Commit abaa0e7

Browse files
Moved tests out of run_in_graph_and_eager_mode in connected components. (#1411)
See #1328
1 parent 83c1ba2 commit abaa0e7

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

tensorflow_addons/image/connected_components_test.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,24 @@ def testOnes(self):
129129
np.tile(np.arange(100)[:, None, None] + 1, [1, 20, 50]),
130130
)
131131

132-
def testOnes_small(self):
133132

134-
self.assertAllEqual(
135-
self.evaluate(connected_components(tf.ones((3, 5), tf.bool))),
136-
np.ones((3, 5)),
137-
)
133+
@pytest.mark.usefixtures("maybe_run_functions_eagerly")
134+
def test_ones_small():
135+
136+
np.testing.assert_equal(
137+
connected_components(tf.ones((3, 5), tf.bool)).numpy(), np.ones((3, 5)),
138+
)
138139

139-
def testRandom_scipy(self):
140-
np.random.seed(42)
141-
images = np.random.randint(0, 2, size=(10, 100, 200)).astype(np.bool)
142-
expected = connected_components_reference_implementation(images)
143-
if expected is None:
144-
return
145140

146-
self.assertAllEqual(self.evaluate(connected_components(images)), expected)
141+
@pytest.mark.usefixtures("maybe_run_functions_eagerly")
142+
def test_random_scipy():
143+
np.random.seed(42)
144+
images = np.random.randint(0, 2, size=(10, 100, 200)).astype(np.bool)
145+
expected = connected_components_reference_implementation(images)
146+
if expected is None:
147+
return
148+
149+
np.testing.assert_equal(connected_components(images).numpy(), expected)
147150

148151

149152
def connected_components_reference_implementation(images):

0 commit comments

Comments
 (0)