Skip to content

Moved tests out of run_in_graph_and_eager_mode in connected components. #1411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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