示例#1
0
def test_image_input_with_three_dim():
    x = utils.generate_data(shape=(32, 32))
    adapter = input_adapter.ImageInputAdapter()
    x = adapter.transform(x)
    assert isinstance(x, tf.data.Dataset)
    for a in x:
        assert a.shape[1:] == (32, 32, 1)
        break
示例#2
0
def test_image_input_numerical():
    x = np.array([[["unknown"]]])
    adapter = input_adapter.ImageInputAdapter()
    with pytest.raises(TypeError) as info:
        x = adapter.transform(x)
    assert "Expect the data to ImageInput to be numerical" in str(info.value)
示例#3
0
def test_image_input_unsupported_type():
    x = "unknown"
    adapter = input_adapter.ImageInputAdapter()
    with pytest.raises(TypeError) as info:
        x = adapter.transform(x)
    assert "Expect the data to ImageInput to be numpy" in str(info.value)
示例#4
0
def test_image_input_with_illegal_dim():
    x = utils.generate_data(shape=(32, ))
    adapter = input_adapter.ImageInputAdapter()
    with pytest.raises(ValueError) as info:
        x = adapter.transform(x)
    assert "Expect the data to ImageInput to have 3" in str(info.value)
示例#5
0
def test_image_input_adapter_shape_is_list():
    x = utils.generate_data()
    adapter = input_adapter.ImageInputAdapter()
    adapter.fit_transform(x)
    assert isinstance(adapter.shape, list)
    assert all(map(lambda x: isinstance(x, int), adapter.shape))
示例#6
0
def test_image_input_adapter_transform_to_dataset():
    x = utils.generate_data()
    adapter = input_adapter.ImageInputAdapter()
    assert isinstance(adapter.transform(x), tf.data.Dataset)
示例#7
0
def test_image_input():
    x = utils.generate_data()
    input_node = input_adapter.ImageInputAdapter()
    assert isinstance(input_node.transform(x), tf.data.Dataset)
示例#8
0
def test_image_input_numerical():
    x = np.array([[['unknown']]])
    input_node = input_adapter.ImageInputAdapter()
    with pytest.raises(TypeError) as info:
        x = input_node.transform(x)
    assert 'Expect the data to ImageInput to be numerical' in str(info.value)