Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add approx comparison to avoid failures in the tests #167

Merged
merged 1 commit into from
Apr 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions python/tests/correlation/test_entropy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy
import math
from functools import partial
import pytest


def my_euclidean(a, b):
Expand All @@ -13,13 +14,13 @@ def test_entropy():
v = numpy.float_([[5, 5], [2, 2], [3, 3], [5, 1]])
entropy = partial(Entropy, p=3, k=2)

assert entropy()(v) == 1.014045451620507
assert entropy(metric=Euclidean())(v) == 1.014045451620507
assert entropy(metric=Manhatten())(v) == 1.582185490039048
assert entropy(metric=Chebyshev())(v) == -3.9489104772539405
assert entropy(metric=P_norm())(v) == 1.582185490039048
assert entropy(metric=P_norm(p=10))(v) == -1.6957132689132957
assert entropy(metric=my_euclidean)(v) == 1.014045451620507 # different value because of hardcoded Euclidean (p)
assert pytest.approx(entropy()(v), 1.014045451620507)
assert pytest.approx(entropy(metric=Euclidean())(v), 1.014045451620507)
assert pytest.approx(entropy(metric=Manhatten())(v), 1.582185490039048)
assert pytest.approx(entropy(metric=Chebyshev())(v), -3.9489104772539405)
assert pytest.approx(entropy(metric=P_norm())(v), 1.582185490039048)
assert pytest.approx(entropy(metric=P_norm(p=10))(v), -1.6957132689132957)
assert pytest.approx(entropy(metric=my_euclidean)(v), 1.014045451620507)


def test_estimate():
Expand Down