Пример #1
0
def test_wap_qhullerror():
    """"Test that SciPy raises a QhullError when there are too few points (at
    least 4 are needed)"""
    X_pc_2 = np.array([[[0., 1.], [1., 2.], [2., 3.]]])
    wap = WeakAlphaPersistence()
    with pytest.raises(QhullError):
        wap.fit_transform(X_pc_2)
Пример #2
0
def test_wap_transform(X, max_edge_length, infinity_values):
    wap = WeakAlphaPersistence(max_edge_length=max_edge_length,
                               infinity_values=infinity_values)
    # This is not generally true, it is only a way to obtain the res array
    # in this specific case
    X_exp = X_wap_exp.copy()
    X_exp[:, :, :2][X_exp[:, :, :2] >= max_edge_length] = infinity_values
    assert_almost_equal(wap.fit_transform(X), X_exp)
Пример #3
0
def test_wap_low_infinity_values(X):
    wap = WeakAlphaPersistence(max_edge_length=0.001, infinity_values=-1)
    assert_almost_equal(wap.fit_transform(X)[:, :, :2], np.zeros((1, 2, 2)))
Пример #4
0
def test_wap_list_of_arrays_different_size():
    X = [X_pc[0], X_pc[0][:-1]]
    wap = WeakAlphaPersistence()
    assert_almost_equal(wap.fit_transform(X)[0], X_wap_exp[0])
Пример #5
0
def test_wap_params():
    coeff = 'not_defined'
    wap = WeakAlphaPersistence(coeff=coeff)

    with pytest.raises(TypeError):
        wap.fit_transform(X_pc)