summaryrefslogtreecommitdiff
path: root/src/python/test/test_representations.py
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2022-11-14 16:24:30 +0100
committerMarc Glisse <marc.glisse@inria.fr>2022-11-14 16:35:47 +0100
commit2f0db9e495afe774409f4b0acb823e1b984aeb71 (patch)
tree63b694cedaed80ec9db4ece742267664234a487e /src/python/test/test_representations.py
parent2ebdeb905d3ca90e2ba2d24e6d3aac52240f6c86 (diff)
endpoints for Entropy, idempotent fit(), refactor grid_
Diffstat (limited to 'src/python/test/test_representations.py')
-rwxr-xr-xsrc/python/test/test_representations.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/python/test/test_representations.py b/src/python/test/test_representations.py
index 9e94feeb..ae0362f8 100755
--- a/src/python/test/test_representations.py
+++ b/src/python/test/test_representations.py
@@ -161,7 +161,7 @@ def test_entropy_miscalculation():
return -np.dot(l, np.log(l))
sce = Entropy(mode="scalar")
assert [[pe(diag_ex)]] == sce.fit_transform([diag_ex])
- sce = Entropy(mode="vector", resolution=4, normalized=False)
+ sce = Entropy(mode="vector", resolution=4, normalized=False, keep_endpoints=True)
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),
@@ -170,7 +170,7 @@ def test_entropy_miscalculation():
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
+ assert area==pytest.approx(1)
def test_kernel_empty_diagrams():
empty_diag = np.empty(shape = [0, 2])
@@ -254,10 +254,10 @@ def test_landscape_nan_range():
def test_endpoints():
diags = [ np.array([[2., 3.]]) ]
- for vec in [ Landscape(), Silhouette(), BettiCurve() ]:
+ for vec in [ Landscape(), Silhouette(), BettiCurve(), Entropy(mode="vector") ]:
vec.fit(diags)
assert vec.grid_[0] > 2 and vec.grid_[-1] < 3
- for vec in [ Landscape(keep_endpoints=True), Silhouette(keep_endpoints=True), BettiCurve(keep_endpoints=True) ]:
+ for vec in [ Landscape(keep_endpoints=True), Silhouette(keep_endpoints=True), BettiCurve(keep_endpoints=True), Entropy(mode="vector", keep_endpoints=True)]:
vec.fit(diags)
assert vec.grid_[0] == 2 and vec.grid_[-1] == 3
vec = BettiCurve(resolution=None)