def test_generator_does_not_raise(self): generator_of_stuff = (tf.constant([11, 22]), tf.constant([1, 2])) tf.assert_proper_iterable(generator_of_stuff)
def test_non_iterable_object_raises(self): non_iterable = 1234 with self.assertRaisesRegexp(TypeError, "to be iterable"): tf.assert_proper_iterable(non_iterable)
def test_list_does_not_raise(self): list_of_stuff = [tf.constant([11, 22]), tf.constant([1, 2])] tf.assert_proper_iterable(list_of_stuff)
def test_single_ndarray_raises(self): array = np.array([1, 2, 3]) with self.assertRaisesRegexp(TypeError, "proper"): tf.assert_proper_iterable(array)
def test_single_string_raises(self): mystr = "hello" with self.assertRaisesRegexp(TypeError, "proper"): tf.assert_proper_iterable(mystr)
def test_single_tensor_raises(self): tensor = tf.constant(1) with self.assertRaisesRegexp(TypeError, "proper"): tf.assert_proper_iterable(tensor)
def test_single_sparse_tensor_raises(self): ten = tf.SparseTensor(indices=[[0, 0], [1, 2]], values=[1, 2], shape=[3, 4]) with self.assertRaisesRegexp(TypeError, "proper"): tf.assert_proper_iterable(ten)
def test_list_does_not_raise(self): list_of_stuff = [tf.constant([11, 22]), tf.constant([1, 2])] tf.assert_proper_iterable(list_of_stuff)
def test_generator_does_not_raise(self): generator_of_stuff = (tf.constant([11, 22]), tf.constant([1, 2])) tf.assert_proper_iterable(generator_of_stuff)
def test_non_iterable_object_raises(self): non_iterable = 1234 with self.assertRaisesRegexp(TypeError, "to be iterable"): tf.assert_proper_iterable(non_iterable)
def test_single_string_raises(self): mystr = "hello" with self.assertRaisesRegexp(TypeError, "proper"): tf.assert_proper_iterable(mystr)
def test_single_ndarray_raises(self): array = np.array([1, 2, 3]) with self.assertRaisesRegexp(TypeError, "proper"): tf.assert_proper_iterable(array)
def test_single_sparse_tensor_raises(self): ten = tf.SparseTensor(indices=[[0, 0], [1, 2]], values=[1, 2], shape=[3, 4]) with self.assertRaisesRegexp(TypeError, "proper"): tf.assert_proper_iterable(ten)
def test_single_tensor_raises(self): tensor = tf.constant(1) with self.assertRaisesRegexp(TypeError, "proper"): tf.assert_proper_iterable(tensor)