Skip to content

Commit

Permalink
Add a regression test for FlagserPersistence
Browse files Browse the repository at this point in the history
  • Loading branch information
ulupo committed Sep 1, 2020
1 parent 3d3a84c commit 49eb5dc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion gtda/homology/tests/test_simplicial.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def test_fp_transform_undirected(X, max_edge_weight, infinity_values):
# same as the one of VietorisRipsPersistence
X_exp = X_vrp_exp.copy()

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

Expand All @@ -359,6 +359,17 @@ def test_fp_transform_undirected(X, max_edge_weight, infinity_values):
assert_almost_equal(fp.fit_transform(X), X_exp)


@pytest.mark.parametrize('delta', range(1, 4))
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))


@pytest.mark.parametrize('X', [X_dist, X_dist_list, X_dist_sparse])
@pytest.mark.parametrize('hom_dims', [None, (0,), (1,), (0, 1)])
def test_fp_fit_transform_plot(X, hom_dims):
Expand Down

0 comments on commit 49eb5dc

Please sign in to comment.