summaryrefslogtreecommitdiff
path: root/src/python/test/test_cubical_complex.py
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2020-05-26 19:22:38 +0200
committerMarc Glisse <marc.glisse@inria.fr>2020-05-26 19:22:38 +0200
commit995d7af6c1686c0ded9a1c48b58ab90f3ac69a1b (patch)
tree3112ab67908069b17013d604c9d562f3be24544e /src/python/test/test_cubical_complex.py
parent16e8f92f0635da668f9f4602f4b7bb4086045a9d (diff)
parent80dc3b26a91280f9da8b9630d983499846d42ea6 (diff)
Merge remote-tracking branch 'origin/master' into tomato2
Diffstat (limited to 'src/python/test/test_cubical_complex.py')
-rwxr-xr-xsrc/python/test/test_cubical_complex.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/python/test/test_cubical_complex.py b/src/python/test/test_cubical_complex.py
index fce4875c..d0e4e9e8 100755
--- a/src/python/test/test_cubical_complex.py
+++ b/src/python/test/test_cubical_complex.py
@@ -147,3 +147,30 @@ def test_connected_sublevel_sets():
periodic_dimensions = periodic_dimensions)
assert cub.persistence() == [(0, (2.0, float("inf")))]
assert cub.betti_numbers() == [1, 0, 0]
+
+def test_cubical_generators():
+ cub = CubicalComplex(top_dimensional_cells = [[0, 0, 0], [0, 1, 0], [0, 0, 0]])
+ cub.persistence()
+ g = cub.cofaces_of_persistence_pairs()
+ assert len(g[0]) == 2
+ assert len(g[1]) == 1
+ assert np.array_equal(g[0][0], np.empty(shape=[0,2]))
+ assert np.array_equal(g[0][1], np.array([[7, 4]]))
+ assert np.array_equal(g[1][0], np.array([8]))
+
+def test_cubical_cofaces_of_persistence_pairs_when_pd_has_no_paired_birth_and_death():
+ cubCpx = CubicalComplex(dimensions=[1,2], top_dimensional_cells=[0.0, 1.0])
+ Diag = cubCpx.persistence(homology_coeff_field=2, min_persistence=0)
+ pairs = cubCpx.cofaces_of_persistence_pairs()
+ assert pairs[0] == []
+ assert np.array_equal(pairs[1][0], np.array([0]))
+
+def test_periodic_cofaces_of_persistence_pairs_when_pd_has_no_paired_birth_and_death():
+ perCubCpx = PeriodicCubicalComplex(dimensions=[1,2], top_dimensional_cells=[0.0, 1.0],
+ periodic_dimensions=[True, True])
+ Diag = perCubCpx.persistence(homology_coeff_field=2, min_persistence=0)
+ pairs = perCubCpx.cofaces_of_persistence_pairs()
+ assert pairs[0] == []
+ assert np.array_equal(pairs[1][0], np.array([0]))
+ assert np.array_equal(pairs[1][1], np.array([0, 1]))
+ assert np.array_equal(pairs[1][2], np.array([1]))