From 4924640cdbf7a91abb25480f2efa0faabbd7536f Mon Sep 17 00:00:00 2001 From: fis Date: Sat, 16 Feb 2019 15:48:57 +0800 Subject: [PATCH] Add python test. --- tests/python/test_basic.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/python/test_basic.py b/tests/python/test_basic.py index dc22b4d1ef61..8abaed62c995 100644 --- a/tests/python/test_basic.py +++ b/tests/python/test_basic.py @@ -63,6 +63,12 @@ def test_basic(self): # assert they are the same assert np.sum(np.abs(preds2 - preds)) == 0 + def test_np_view(self): + y = np.array([12, 34, 56], np.float32)[::2] + from_view = xgb.DMatrix([], label=y).get_label() + from_array = xgb.DMatrix([], label=y+0).get_label() + assert (from_view == from_array).all() + def test_record_results(self): dtrain = xgb.DMatrix(dpath + 'agaricus.txt.train') dtest = xgb.DMatrix(dpath + 'agaricus.txt.test')