Skip to content

Moved method out of the run_all_in_graph_and_eager_mode in utils_test.py #1357

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 25, 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
20 changes: 10 additions & 10 deletions tensorflow_addons/image/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ def test_from_4D_image_with_invalid_data(self):
img_utils.from_4D_image(tf.ones(shape=(2, 2, 4, 1)), tf.constant(2))
)

def test_from_4D_image_with_invalid_shape(self):
errors = (ValueError, tf.errors.InvalidArgumentError)
for rank in 2, tf.constant(2):
with self.subTest(rank=rank):
with self.assertRaisesRegexp(errors, "`image` must be 4D tensor"):
img_utils.from_4D_image(tf.ones(shape=(2, 4)), rank)

with self.assertRaisesRegexp(errors, "`image` must be 4D tensor"):
img_utils.from_4D_image(tf.ones(shape=(2, 4, 1)), rank)
@pytest.mark.parametrize("rank", [2, tf.constant(2)])
def test_from_4d_image_with_invalid_shape(rank):
errors = (ValueError, tf.errors.InvalidArgumentError)
with pytest.raises(errors, match="`image` must be 4D tensor"):
img_utils.from_4D_image(tf.ones(shape=(2, 4)), rank)

with pytest.raises(errors, match="`image` must be 4D tensor"):
img_utils.from_4D_image(tf.ones(shape=(2, 4, 1)), rank)

with self.assertRaisesRegexp(errors, "`image` must be 4D tensor"):
img_utils.from_4D_image(tf.ones(shape=(1, 2, 4, 1, 1)), rank)
with pytest.raises(errors, match="`image` must be 4D tensor"):
img_utils.from_4D_image(tf.ones(shape=(1, 2, 4, 1, 1)), rank)


if __name__ == "__main__":
Expand Down