add one last test for branch coverage
@@ -16,7 +16,7 @@ from dit.inference.knn_estimators import differential_entropy_knn, total_correla
@settings(deadline=None, timeout=unlimited, max_examples=25)
@given(mean=floats(min_value=-2.0, max_value=2.0),
std=floats(min_value=0.1, max_value=2.0))
-def test_entropy_knn(mean, std):
+def test_entropy_knn1(mean, std):
"""
Test entropy of normal samples.
"""
@@ -26,11 +26,24 @@ def test_entropy_knn(mean, std):
assert h == pytest.approx(np.log2(2*np.pi*np.e*std**2)/2, abs=1e-1)
+@settings(deadline=None, timeout=unlimited, max_examples=25)
+@given(mean=floats(min_value=-2.0, max_value=2.0),
+ std=floats(min_value=0.1, max_value=2.0))
+def test_entropy_knn2(mean, std):
+ """
+ Test entropy of normal samples.
+ """
+ n = 100000
+ data = np.random.normal(mean, std, n).reshape(n, 1)
+ h = differential_entropy_knn(data, [1])
+ assert h == pytest.approx(np.log2(2*np.pi*np.e*std**2)/2, abs=1e-1)
+
+
@settings(deadline=None, max_examples=5)
@given(means=lists(floats(min_value=-2.0, max_value=2.0), min_size=2, max_size=2),
stds=lists(floats(min_value=0.1, max_value=2.0), min_size=2, max_size=2),
rho=floats(min_value=-0.9, max_value=0.9))
-def test_mi_knn(means, stds, rho):
+def test_mi_knn1(means, stds, rho):
"""
Test entropy of normal samples.
"""
@@ -45,7 +58,7 @@ def test_mi_knn(means, stds, rho):
@given(means=lists(floats(min_value=-2.0, max_value=2.0), min_size=3, max_size=3),
stds=lists(floats(min_value=0.1, max_value=2.0), min_size=3, max_size=3),
rho=floats(min_value=-0.9, max_value=0.9))
-def test_cmi_knn(means, stds, rho):
+def test_cmi_knn1(means, stds, rho):
"""
Test entropy of normal samples.
"""
