Add back support for scipy.sparse.coo_matrix (#6162)

This commit is contained in:
Philip Hyunsu Cho
2020-09-25 00:49:49 -07:00
committed by GitHub
parent 72ef553550
commit bd2b1eabd0
2 changed files with 20 additions and 0 deletions

View File

@@ -76,6 +76,15 @@ class TestDMatrix(unittest.TestCase):
assert dtrain.num_row() == 3
assert dtrain.num_col() == 3
def test_coo(self):
row = np.array([0, 2, 2, 0, 1, 2])
col = np.array([0, 0, 1, 2, 2, 2])
data = np.array([1, 2, 3, 4, 5, 6])
X = scipy.sparse.coo_matrix((data, (row, col)), shape=(3, 3))
dtrain = xgb.DMatrix(X)
assert dtrain.num_row() == 3
assert dtrain.num_col() == 3
def test_np_view(self):
# Sliced Float32 array
y = np.array([12, 34, 56], np.float32)[::2]