コード例 #1
0
def test_simple_evluation():
    """Evaluate a model with a simple example feature vector."""
    # Get model file
    current_folder = os.path.dirname(os.path.realpath(__file__))
    misc_folder = os.path.join(current_folder, "misc")
    model_file = os.path.join(misc_folder, "model.tar")
    assert os.path.isfile(model_file)

    features = [0 for i in range(167)]

    evaluate.main(model_file, features)

    # Test the bash version
    fd, feature_file = tempfile.mkstemp(".json")
    with open(feature_file, "w") as outfile:
        json.dump(features, outfile)
    evaluate.main_bash(model_file, feature_file)
    os.remove(feature_file)
コード例 #2
0
def simple_evluation_test():
    """Evaluate a model with a simple example feature vector."""
    # Get model file
    current_folder = os.path.dirname(os.path.realpath(__file__))
    misc_folder = os.path.join(current_folder, "misc")
    model_file = os.path.join(misc_folder, "model.tar")
    nose.tools.assert_equal(os.path.isfile(model_file), True)

    features = [0 for i in range(167)]

    evaluate.main(model_file, features)

    # Test the bash version
    fd, feature_file = tempfile.mkstemp('.json')
    with open(feature_file, "w") as outfile:
        json.dump(features, outfile)
    evaluate.main_bash(model_file, feature_file)
    os.remove(feature_file)
コード例 #3
0
def test_non_tarfile_model_file():
    """Check what happens when a non-tarfile model file is given to the main
    evaluate method.
    """
    # Get model file
    current_folder = os.path.dirname(os.path.realpath(__file__))
    misc_folder = os.path.join(current_folder, "misc")
    model_file = os.path.join(misc_folder, "features.json")
    features = [0 for i in range(167)]

    evaluation_result = evaluate.main(model_file, features)
    assert evaluation_result == []
コード例 #4
0
def non_tarfile_model_file_test():
    """Check what happens when a non-tarfile model file is given to the main
    evaluate method.
    """
    # Get model file
    current_folder = os.path.dirname(os.path.realpath(__file__))
    misc_folder = os.path.join(current_folder, "misc")
    model_file = os.path.join(misc_folder, "features.json")
    features = [0 for i in range(167)]

    evaluation_result = evaluate.main(model_file, features)
    nose.tools.assert_equal([], evaluation_result)
コード例 #5
0
def non_existing_model_file_test():
    """Check what happens when a non-existing model file is given to the main
    evaluate method.
    """
    # Get model file
    current_folder = os.path.dirname(os.path.realpath(__file__))
    misc_folder = os.path.join(current_folder, "misc")
    model_file = os.path.join(misc_folder, "model-nonexistent.tar")
    features = [0 for i in range(167)]

    evaluation_result = evaluate.main(model_file, features)
    nose.tools.assert_equal([], evaluation_result)