Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jungtaekkim committed Nov 18, 2024
1 parent 50e26c7 commit 240bb32
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions tests/common/test_gp_likelihood.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# author: Jungtaek Kim ([email protected])
# last updated: March 22, 2021
# author: Jungtaek Kim ([email protected])
# last updated: November 18, 2024
#
"""test_gp_likelihood"""

Expand All @@ -13,9 +13,6 @@
from bayeso.utils import utils_covariance


TEST_EPSILON = 1e-7


def test_neg_log_ml_typing():
annos = package_target.neg_log_ml.__annotations__

Expand Down Expand Up @@ -85,7 +82,7 @@ def test_neg_log_ml():
)
print(neg_log_ml_)
truth_log_ml_ = 21.916650988532854
assert np.abs(neg_log_ml_ - truth_log_ml_) < TEST_EPSILON
np.testing.assert_allclose(neg_log_ml_, truth_log_ml_)

neg_log_ml_ = package_target.neg_log_ml(
X,
Expand All @@ -99,7 +96,7 @@ def test_neg_log_ml():
)
print(neg_log_ml_)
truth_log_ml_ = 21.91665090519953
assert np.abs(neg_log_ml_ - truth_log_ml_) < TEST_EPSILON
np.testing.assert_allclose(neg_log_ml_, truth_log_ml_)

neg_log_ml_ = package_target.neg_log_ml(
X,
Expand All @@ -113,7 +110,7 @@ def test_neg_log_ml():
)
print(neg_log_ml_)
truth_log_ml_ = 21.91665090519953
assert np.abs(neg_log_ml_ - truth_log_ml_) < TEST_EPSILON
np.testing.assert_allclose(neg_log_ml_, truth_log_ml_)

neg_log_ml_, neg_grad_log_ml_ = package_target.neg_log_ml(
X,
Expand Down Expand Up @@ -141,8 +138,8 @@ def test_neg_log_ml():
-0.00029606081917620415,
]
)
assert np.abs(neg_log_ml_ - truth_log_ml_) < TEST_EPSILON
assert np.all(np.abs(neg_grad_log_ml_ - truth_grad_log_ml_) < TEST_EPSILON)
np.testing.assert_allclose(neg_log_ml_, truth_log_ml_)
np.testing.assert_allclose(neg_grad_log_ml_, truth_grad_log_ml_)


def test_neg_log_pseudo_l_loocv_typing():
Expand Down Expand Up @@ -211,4 +208,4 @@ def test_neg_log_pseudo_l_loocv():
)
print(neg_log_pseudo_l_)
truth_log_pseudo_l_ = 21.916822991658695
assert np.abs(neg_log_pseudo_l_ - truth_log_pseudo_l_) < TEST_EPSILON
np.testing.assert_allclose(neg_log_pseudo_l_, truth_log_pseudo_l_)

0 comments on commit 240bb32

Please sign in to comment.