From 49eb5dcec4009db5edc3f91f653e027da48ff8c5 Mon Sep 17 00:00:00 2001 From: Umberto Lupo Date: Wed, 2 Sep 2020 01:48:24 +0200 Subject: [PATCH] Add a regression test for FlagserPersistence --- gtda/homology/tests/test_simplicial.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gtda/homology/tests/test_simplicial.py b/gtda/homology/tests/test_simplicial.py index 8735614eb..bc5ed8f5e 100644 --- a/gtda/homology/tests/test_simplicial.py +++ b/gtda/homology/tests/test_simplicial.py @@ -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.] @@ -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):