summaryrefslogtreecommitdiff
path: root/src/python/test/test_cubical_complex.py
diff options
context:
space:
mode:
authorROUVREAU Vincent <vincent.rouvreau@inria.fr>2019-12-16 23:10:24 +0100
committerROUVREAU Vincent <vincent.rouvreau@inria.fr>2019-12-16 23:10:24 +0100
commitb5510c0c362cd2bef79d82fd9809e654aea73957 (patch)
tree926ab134ff6e2e93b30deae8dcc1782913163944 /src/python/test/test_cubical_complex.py
parent3f1601665cbd0b7397c9c19f55d608246192207b (diff)
Add numpy ndarray to init a cubical and a periodic one
Diffstat (limited to 'src/python/test/test_cubical_complex.py')
-rwxr-xr-xsrc/python/test/test_cubical_complex.py33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/python/test/test_cubical_complex.py b/src/python/test/test_cubical_complex.py
index 68f54fbe..a37d7821 100755
--- a/src/python/test/test_cubical_complex.py
+++ b/src/python/test/test_cubical_complex.py
@@ -1,4 +1,5 @@
from gudhi import CubicalComplex
+import numpy as np
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
@@ -56,7 +57,7 @@ def test_dimension_or_perseus_file_constructor():
assert cub.__is_persistence_defined() == False
-def test_dimension_simple_constructor():
+def simple_constructor(cub):
cub = CubicalComplex(
dimensions=[3, 3], top_dimensional_cells=[1, 2, 3, 4, 5, 6, 7, 8, 9]
)
@@ -67,12 +68,22 @@ def test_dimension_simple_constructor():
assert cub.betti_numbers() == [1, 0, 0]
assert cub.persistent_betti_numbers(0, 1000) == [0, 0, 0]
-
-def test_user_case_simple_constructor():
+def test_simple_constructor_from_top_cells():
cub = CubicalComplex(
dimensions=[3, 3],
- top_dimensional_cells=[float("inf"), 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0],
+ top_dimensional_cells=[1, 2, 3, 4, 5, 6, 7, 8, 9],
)
+ simple_constructor(cub)
+
+def test_simple_constructor_from_numpy_array():
+ cub = CubicalComplex(
+ numpy_array=np.array([[1, 2, 3],
+ [4, 5, 6],
+ [7, 8, 9]])
+ )
+ simple_constructor(cub)
+
+def user_case_simple_constructor(cub):
assert cub.__is_defined() == True
assert cub.__is_persistence_defined() == False
assert cub.persistence() == [(1, (0.0, 1.0)), (0, (0.0, float("inf")))]
@@ -83,6 +94,20 @@ def test_user_case_simple_constructor():
)
assert other_cub.persistence() == [(1, (0.0, 1.0)), (0, (0.0, float("inf")))]
+def test_user_case_simple_constructor_from_top_cells():
+ cub = CubicalComplex(
+ dimensions=[3, 3],
+ top_dimensional_cells=[float("inf"), 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0],
+ )
+ user_case_simple_constructor(cub)
+
+def test_user_case_simple_constructor_from_numpy_array():
+ cub = CubicalComplex(
+ numpy_array=np.array([[float("inf"), 0.0, 0.0],
+ [0.0, 1.0, 0.0],
+ [0.0, 0.0, 0.0]])
+ )
+ user_case_simple_constructor(cub)
def test_dimension_file_constructor():
# Create test file