diff options
author | Manu <msoriano4@us.es> | 2022-02-23 19:20:06 +0100 |
---|---|---|
committer | Manu <msoriano4@us.es> | 2022-02-23 19:20:06 +0100 |
commit | 758111506dfb99cdc59981395386926e178d447c (patch) | |
tree | 4b5adc1e7d20670e4d587112fbfec9e53545f2de /src/python/test/test_representations.py | |
parent | 3b7bd4fd8b21fc8ce0d7b2848b5ac9bdd397c080 (diff) |
a test for gudhi.representations.Entropy has been added
Diffstat (limited to 'src/python/test/test_representations.py')
-rwxr-xr-x | src/python/test/test_representations.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/python/test/test_representations.py b/src/python/test/test_representations.py index 6a3dddc4..553ceba0 100755 --- a/src/python/test/test_representations.py +++ b/src/python/test/test_representations.py @@ -160,7 +160,17 @@ 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]) |