Beispiel #1
0
def test_fp_transform_high_hom_dim(delta):
    """Test that if the maximum homology dimension is greater than or equal to
    the number of points, we do not produce errors."""
    n_points = 3
    X = X_dist[:, :n_points, :n_points]
    fp = FlagserPersistence(homology_dimensions=list(range(n_points + delta)))
    assert_almost_equal(
        fp.fit_transform(X)[0, -1],
        np.array([0., 0., n_points + delta - 1], dtype=float))
Beispiel #2
0
def test_fp_transform_directed(max_edge_weight, infinity_values):
    fp = FlagserPersistence(directed=True, max_edge_weight=max_edge_weight,
                            infinity_values=infinity_values)
    # In the undirected case with "max" filtration, the results are always the
    # same as the one of VietorisRipsPersistence
    X_res = X_fp_dir_res.copy()
    # This is not generally true, it is only a way to obtain the res array
    # in this specific case
    X_res[:, :, :2][X_res[:, :, :2] >= max_edge_weight] = infinity_values
    assert_almost_equal(fp.fit_transform(X_dir_graph), X_res)
Beispiel #3
0
def test_fp_transform_undirected(max_edge_weight, infinity_values):
    fp = FlagserPersistence(directed=False, max_edge_weight=max_edge_weight,
                            infinity_values=infinity_values)
    # In the undirected case with "max" filtration, the results are always the
    # same as the one of VietorisRipsPersistence
    X_res = X_vrp_res.copy()

    # In that case, subdiagrams of dimension 1 is empty
    if max_edge_weight == 0.6:
        X_res[0, -1, :] = [0., 0., 1.]

    # This is not generally true, it is only a way to obtain the res array
    # in this specific case
    X_res[:, :, :2][X_res[:, :, :2] >= max_edge_weight] = infinity_values
    assert_almost_equal(fp.fit_transform(X_dist), X_res)
Beispiel #4
0
def test_fp_fit_transform_plot(X, hom_dims):
    FlagserPersistence(directed=False).fit_transform_plot(
        X_dist, sample=0, homology_dimensions=hom_dims)
Beispiel #5
0
def test_fp_not_fitted():
    fp = FlagserPersistence()

    with pytest.raises(NotFittedError):
        fp.transform(X_dist)
Beispiel #6
0
def test_fp_params():
    coeff = 'not_defined'
    fp = FlagserPersistence(coeff=coeff)

    with pytest.raises(TypeError):
        fp.fit_transform(X_dist)