summaryrefslogtreecommitdiff
path: root/src/python/test/test_representations.py
diff options
context:
space:
mode:
authorManu <msoriano4@us.es>2022-02-23 19:31:48 +0100
committerManu <msoriano4@us.es>2022-02-23 19:31:48 +0100
commit9c0b0d348b448d68d28fbab661626ab2263e77d0 (patch)
treefbfa9d3a949355a1c3b69ec5e98eba7004eff7f6 /src/python/test/test_representations.py
parenta1e8821384c58f7d843a3271f909c31c26649032 (diff)
A test of gudhi.representations.Entropy has been added
Diffstat (limited to 'src/python/test/test_representations.py')
-rwxr-xr-xsrc/python/test/test_representations.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/python/test/test_representations.py b/src/python/test/test_representations.py
index 6a3dddc4..4a455bb6 100755
--- a/src/python/test/test_representations.py
+++ b/src/python/test/test_representations.py
@@ -160,8 +160,18 @@ def test_entropy_miscalculation():
l = l/sum(l)
return -np.dot(l, np.log(l))
sce = Entropy(mode="scalar")
- assert [[pe_max(diag_ex)]] == sce.fit_transform([diag_ex])
-
+ assert [[pe(diag_ex)]] == sce.fit_transform([diag_ex])
+ sce = Entropy(mode="vector", resolution=4, normalized=False)
+ pef = [-1/4*np.log(1/4)-1/4*np.log(1/4)-1/2*np.log(1/2),
+ -1/4*np.log(1/4)-1/4*np.log(1/4)-1/2*np.log(1/2),
+ -1/2*np.log(1/2),
+ 0.0]
+ assert all(([pef] == sce.fit_transform([diag_ex]))[0])
+ sce = Entropy(mode="vector", resolution=4, normalized=True)
+ pefN = (sce.fit_transform([diag_ex]))[0]
+ area = np.linalg.norm(pefN, ord=1)
+ assert area==1
+
def test_kernel_empty_diagrams():
empty_diag = np.empty(shape = [0, 2])
assert SlicedWassersteinDistance(num_directions=100)(empty_diag, empty_diag) == 0.