Ejemplo n.º 1
0
def test_cfg_to_algorithm_pass_2(write_yaml):
    """ Test ``yatsm.classification.cfg_to_algorithm`` with an empty config
    """
    cfg = {
        'algorithm': 'RandomForest',
        'RandomForest': {'init': {}, 'fit': {}}
    }
    classification.cfg_to_algorithm(write_yaml(cfg))
Ejemplo n.º 2
0
def test_cfg_to_algorithm_fail_2(write_yaml):
    """ Fail because algorithm parameters don't exist
    """
    cfg = {
        'algorithm': 'RandomForest',
        'RandomForest': {'init': {'not_a_param': 42}, 'fit': {}}
    }
    with pytest.raises(TypeError):
        classification.cfg_to_algorithm(write_yaml(cfg))
Ejemplo n.º 3
0
def test_cfg_to_algorithm_pass_2(write_yaml):
    """ Test ``yatsm.classification.cfg_to_algorithm`` with an empty config
    """
    cfg = {
        'algorithm': 'RandomForest',
        'RandomForest': {
            'init': {},
            'fit': {}
        }
    }
    classification.cfg_to_algorithm(write_yaml(cfg))
Ejemplo n.º 4
0
def test_cfg_to_algorithm_fail_2(write_yaml):
    """ Fail because algorithm parameters don't exist
    """
    cfg = {
        'algorithm': 'RandomForest',
        'RandomForest': {
            'init': {
                'not_a_param': 42
            },
            'fit': {}
        }
    }
    with pytest.raises(TypeError):
        classification.cfg_to_algorithm(write_yaml(cfg))
Ejemplo n.º 5
0
def test_cfg_to_algorithm_fail_3(tmpdir):
    """ Fail because we don't use a YAML file
    """
    f = tmpdir.mkdir('clf').join('test').strpath
    with pytest.raises(IOError):
        classification.cfg_to_algorithm(f)
Ejemplo n.º 6
0
def test_cfg_to_algorithm_fail_1(write_yaml):
    """ Fail because algorithm in config doesn't exist
    """
    cfg = {'algorithm': 'hopefully_not_an_algo'}
    with pytest.raises(AlgorithmNotFoundException):
        classification.cfg_to_algorithm(write_yaml(cfg))
Ejemplo n.º 7
0
def test_cfg_to_algorithm_fail_3(tmpdir):
    """ Fail because we don't use a YAML file
    """
    f = tmpdir.mkdir('clf').join('test').strpath
    with pytest.raises(IOError):
        classification.cfg_to_algorithm(f)
Ejemplo n.º 8
0
def test_cfg_to_algorithm_fail_1(write_yaml):
    """ Fail because algorithm in config doesn't exist
    """
    cfg = {'algorithm': 'hopefully_not_an_algo'}
    with pytest.raises(AlgorithmNotFoundException):
        classification.cfg_to_algorithm(write_yaml(cfg))