def test_text_dataset_batch(): x = tf.data.Dataset.from_tensor_slices(np.array(["a b c", "b b c"])).batch(32) adapter = input_adapter.TextInputAdapter() x = adapter.transform(x) assert data_utils.dataset_shape(x).as_list() == [None, 1] assert isinstance(x, tf.data.Dataset)
def test_text_np(): x = np.array([ 'a b c', 'b b c', ]) adapter = input_adapter.TextInputAdapter() x = adapter.transform(x) assert data_utils.dataset_shape(x).as_list() == [None, 1] assert isinstance(x, tf.data.Dataset)
def test_text_string(): x = np.array([1, 2]) adapter = input_adapter.TextInputAdapter() with pytest.raises(TypeError) as info: x = adapter.transform(x) assert "Expect the data to TextInput to be strings" in str(info.value)
def test_text_input_with_illegal_dim(): x = utils.generate_data(shape=(32, )) adapter = input_adapter.TextInputAdapter() with pytest.raises(ValueError) as info: x = adapter.transform(x) assert "Expect the data to TextInput to have 1" in str(info.value)
def test_text_input_type_error(): x = "unknown" adapter = input_adapter.TextInputAdapter() with pytest.raises(TypeError) as info: x = adapter.transform(x) assert "Expect the data to TextInput to be numpy" in str(info.value)
def test_text_input_type_error(): x = 'unknown' input_node = input_adapter.TextInputAdapter() with pytest.raises(TypeError) as info: x = input_node.transform(x) assert 'Expect the data to TextInput to be numpy' in str(info.value)