From 9df728478a94e7750c265b4ce8100086de329502 Mon Sep 17 00:00:00 2001 From: adamingas Date: Thu, 11 Jan 2024 22:30:50 +0000 Subject: [PATCH] fix: add assertions in hessian monotonic test --- tests/test_loss.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/test_loss.py b/tests/test_loss.py index 0b16f14..deae449 100644 --- a/tests/test_loss.py +++ b/tests/test_loss.py @@ -107,8 +107,18 @@ def test_hessian_ordinal_logistic_nll_monotonic(): y_preds = np.linspace(0,150,100) y_true = np.array([5]*100) theta = np.arange(0,18,2) - + expected_max_mask = np.logical_and(y_predstheta[4]) hessian = hessian_ordinal_logistic_nll(y_true, y_preds, theta) + np.testing.assert_almost_equal(hessian[expected_max_mask], hessian.max()) + + expected_max_indx = np.where(expected_max_mask)[0] + ascending = hessian[:expected_max_indx[0]] + assert ((ascending[1:] - ascending[:-1]) >=0).all() + + descending = hessian[expected_max_indx[0]:] + assert ((descending[1:] - descending[:-1]) <=0).all() + + def test_lgb_ordinal_loss(): y_preds = np.array([1.5, 15, -38])