Skip to content

Commit

Permalink
Moved tests out of run_in_graph_and_eager_mode in connected component…
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldemarmiesse authored Mar 26, 2020
1 parent 14218cf commit 66fdbcf
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions tensorflow_addons/image/connected_components_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,24 @@ def testOnes(self):
np.tile(np.arange(100)[:, None, None] + 1, [1, 20, 50]),
)

def testOnes_small(self):

self.assertAllEqual(
self.evaluate(connected_components(tf.ones((3, 5), tf.bool))),
np.ones((3, 5)),
)
@pytest.mark.usefixtures("maybe_run_functions_eagerly")
def test_ones_small():

np.testing.assert_equal(
connected_components(tf.ones((3, 5), tf.bool)).numpy(), np.ones((3, 5)),
)

def testRandom_scipy(self):
np.random.seed(42)
images = np.random.randint(0, 2, size=(10, 100, 200)).astype(np.bool)
expected = connected_components_reference_implementation(images)
if expected is None:
return

self.assertAllEqual(self.evaluate(connected_components(images)), expected)
@pytest.mark.usefixtures("maybe_run_functions_eagerly")
def test_random_scipy():
np.random.seed(42)
images = np.random.randint(0, 2, size=(10, 100, 200)).astype(np.bool)
expected = connected_components_reference_implementation(images)
if expected is None:
return

np.testing.assert_equal(connected_components(images).numpy(), expected)


def connected_components_reference_implementation(images):
Expand Down

0 comments on commit 66fdbcf

Please sign in to comment.