summaryrefslogtreecommitdiff
path: root/src/python/test/test_representations.py
diff options
context:
space:
mode:
authorwreise <wojciech.reise@epfl.ch>2022-06-02 10:49:07 +0200
committerwreise <wojciech.reise@epfl.ch>2022-06-02 10:49:07 +0200
commit500de3b265c227eadd81fb860fade4f6c416cfbc (patch)
tree69189e0bb09b9893c94d4d650329299e4151c102 /src/python/test/test_representations.py
parenta1856ab91e594999e3d0f471f2b15fdf6ac0b2c5 (diff)
Add tests for Landscapes
Diffstat (limited to 'src/python/test/test_representations.py')
-rwxr-xr-xsrc/python/test/test_representations.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/python/test/test_representations.py b/src/python/test/test_representations.py
index 8be3a1db..0324b026 100755
--- a/src/python/test/test_representations.py
+++ b/src/python/test/test_representations.py
@@ -197,3 +197,29 @@ def test_silhouette_numeric():
expected_silhouette = np.array([0., 0.5, 0., 0., 0., 0., 0., 0.5, 0.])/np.sqrt(2)
output_silhouette = slt(dgm)
assert np.all(np.isclose(output_silhouette, expected_silhouette))
+
+
+def test_landscape_small_persistence_invariance():
+ dgm = np.array([[2., 6.], [2., 5.], [3., 7.]])
+ small_persistence_pts = np.random.rand(10, 2)
+ small_persistence_pts[:, 1] += small_persistence_pts[:, 0]
+ small_persistence_pts += np.min(dgm)
+ dgm_augmented = np.concatenate([dgm, small_persistence_pts], axis=0)
+
+ lds = Landscape(num_landscapes=2, resolution=5)
+ lds_dgm, lds_dgm_augmented = lds(dgm), lds(dgm_augmented)
+
+ assert np.all(np.isclose(lds_dgm, lds_dgm_augmented))
+
+
+def test_landscape_numeric():
+ dgm = np.array([[2., 6.], [3., 5.]])
+ lds_ref = np.array([
+ 0., 0.5, 1., 1.5, 2., 1.5, 1., 0.5, 0., # tent of [2, 6]
+ 0., 0., 0., 0.5, 1., 0.5, 0., 0., 0.
+ ])
+ lds_ref *= np.sqrt(2)
+ lds = Landscape(num_landscapes=2, resolution=9, sample_range=[2., 6.])
+ lds_dgm = lds(dgm)
+ print(lds.sample_range, lds.new_resolution, lds_dgm.shape)
+ assert np.all(np.isclose(lds_dgm, lds_ref))