From b31d37eac559883e71d2975696cf00fa9ba3be77 Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Fri, 30 Apr 2021 09:00:05 +0800 Subject: [PATCH] [CI] Fix custom metric test with empty dataset. (#6917) --- tests/python/testing.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/python/testing.py b/tests/python/testing.py index 6294964dc..4b2b31e09 100644 --- a/tests/python/testing.py +++ b/tests/python/testing.py @@ -272,6 +272,8 @@ def eval_error_metric(predt, dtrain: xgb.DMatrix): label = dtrain.get_label() r = np.zeros(predt.shape) gt = predt > 0.5 + if predt.size == 0: + return "CustomErr", 0 r[gt] = 1 - label[gt] le = predt <= 0.5 r[le] = label[le]