Skip to content

Commit

Permalink
replace all assert statements with self.assert methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinvtran committed Mar 23, 2017
1 parent 497fb61 commit f1621e5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions tests/test-criticisms/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ def test_classification_metrics(self):
dtype=tf.float32)
y_b = tf.convert_to_tensor(np.random.random((6, 7)))
for metric in all_classification_metrics:
assert metric(y_a, y_b).eval().shape == ()
self.assertEqual(metric(y_a, y_b).eval().shape, ())

def test_sparse_classification_metrics(self):
with self.test_session():
y_a = tf.convert_to_tensor(np.random.randint(0, 7, (6,)),
dtype=tf.float32)
y_b = tf.convert_to_tensor(np.random.random((6, 7)))
for metric in all_sparse_metrics:
assert metric(y_a, y_b).eval().shape == ()
self.assertEqual(metric(y_a, y_b).eval().shape, ())

def test_regression_metrics(self):
with self.test_session():
y_a = tf.convert_to_tensor(np.random.random((6, 7)))
y_b = tf.convert_to_tensor(np.random.random((6, 7)))
for metric in all_regression_metrics:
output = metric(y_a, y_b)
assert output.eval().shape == ()
self.assertEqual(output.eval().shape, ())

if __name__ == '__main__':
tf.test.main()
8 changes: 4 additions & 4 deletions tests/test-models/test_keras_core_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ def test_flatten(self):
x = Normal(mu=tf.zeros([100, 10, 5]), sigma=tf.ones([100, 10, 5]))
y = layers.Flatten()(x)
with self.test_session():
assert y.eval().shape == (100, 50)
self.assertEqual(y.eval().shape, (100, 50))

def test_reshape(self):
x = Normal(mu=tf.zeros([100, 10, 5]), sigma=tf.ones([100, 10, 5]))
y = layers.Reshape((5, 10))(x)
with self.test_session():
assert y.eval().shape == (100, 5, 10)
self.assertEqual(y.eval().shape, (100, 5, 10))

def test_permute(self):
x = Normal(mu=tf.zeros([100, 10, 5]), sigma=tf.ones([100, 10, 5]))
y = layers.Permute((2, 1))(x)
with self.test_session():
assert y.eval().shape == (100, 5, 10)
self.assertEqual(y.eval().shape, (100, 5, 10))

def test_repeat_vector(self):
x = Normal(mu=tf.zeros([100, 10]), sigma=tf.ones([100, 10]))
y = layers.RepeatVector(2)(x)
with self.test_session():
assert y.eval().shape == (100, 2, 10)
self.assertEqual(y.eval().shape, (100, 2, 10))

def test_merge(self):
shared_dense = layers.Dense(32)
Expand Down
8 changes: 4 additions & 4 deletions tests/test-models/test_random_variable_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ def test_abs(self):
def test_hash(self):
x = Normal(mu=0.0, sigma=1.0)
y = 5.0
assert not hash(x) == hash(y)
assert hash(x) == id(x)
self.assertNotEqual(hash(x), hash(y))
self.assertEqual(hash(x), id(x))

def test_eq(self):
x = Normal(mu=0.0, sigma=1.0)
y = 5.0
assert not x == y
assert x == x
self.assertNotEqual(x, y)
self.assertEqual(x, x)

def test_bool_nonzero(self):
with self.test_session() as sess:
Expand Down

0 comments on commit f1621e5

Please sign in to comment.