Exemplo n.º 1
0
def test_opf_read_distances():
    try:
        clf = opf.OPF(pre_computed_distance='data/boat')
    except:
        clf = opf.OPF(pre_computed_distance='data/boat.txt')

    assert clf.pre_distances.shape == (100, 4)

    try:
        clf = opf.OPF(pre_computed_distance='data/boa.txt')
    except:
        clf = opf.OPF(pre_computed_distance='data/boat.csv')

    assert clf.pre_distances.shape == (100, 4)
Exemplo n.º 2
0
def test_opf_subgraph():
    clf = opf.OPF()

    try:
        clf.subgraph = 'a'
    except:
        clf.subgraph = Subgraph()

    assert isinstance(clf.subgraph, Subgraph)
Exemplo n.º 3
0
def test_opf_pre_distances():
    clf = opf.OPF()

    try:
        clf.pre_distances = 'a'
    except:
        clf.pre_distances = np.ones(10)

    assert clf.pre_distances.shape == (10, )
Exemplo n.º 4
0
def test_opf_pre_computed_distance():
    clf = opf.OPF()

    try:
        clf.pre_computed_distance = 'a'
    except:
        clf.pre_computed_distance = False

    assert clf.pre_computed_distance == False
Exemplo n.º 5
0
def test_opf_distance_fn():
    clf = opf.OPF()

    try:
        clf.distance_fn = 'a'
    except:
        clf.distance_fn = callable

    assert clf.distance_fn == callable
Exemplo n.º 6
0
def test_opf_distance():
    clf = opf.OPF()

    try:
        clf.distance = 'a'
    except:
        clf.distance = 'euclidean'

    assert clf.distance == 'euclidean'
Exemplo n.º 7
0
def test_opf_fit():
    clf = opf.OPF()

    with pytest.raises(NotImplementedError):
        clf.fit(None, None)
Exemplo n.º 8
0
def test_opf_load():
    clf = opf.OPF()

    clf.load('data/test.pkl')

    assert clf.distance == 'bray_curtis'
Exemplo n.º 9
0
def test_opf_save():
    clf = opf.OPF(distance='bray_curtis')

    clf.save('data/test.pkl')

    assert os.path.isfile('data/test.pkl')
Exemplo n.º 10
0
def test_opf_predict():
    clf = opf.OPF()

    with pytest.raises(NotImplementedError):
        clf.predict(None)