Use array interface for CSC matrix. (#8672)
* Use array interface for CSC matrix. Use array interface for CSC matrix and align the interface with CSR and dense. - Fix nthread issue in the R package DMatrix. - Unify the behavior of handling `missing` with other inputs. - Unify the behavior of handling `missing` around R, Python, Java, and Scala DMatrix. - Expose `num_non_missing` to the JVM interface. - Deprecate old CSR and CSC constructors.
This commit is contained in:
@@ -82,10 +82,6 @@ class TestDMatrix:
|
||||
|
||||
assert len(record) == 0
|
||||
|
||||
with pytest.warns(UserWarning):
|
||||
csr = csr_matrix(x)
|
||||
xgb.DMatrix(csr.tocsc(), y, missing=4)
|
||||
|
||||
def test_dmatrix_numpy_init(self):
|
||||
data = np.random.randn(5, 5)
|
||||
dm = xgb.DMatrix(data)
|
||||
@@ -130,6 +126,12 @@ class TestDMatrix:
|
||||
assert dtrain.num_row() == 3
|
||||
assert dtrain.num_col() == 3
|
||||
|
||||
indptr = np.array([0, 3, 5])
|
||||
data = np.array([0, 1, 2, 3, 4])
|
||||
row_idx = np.array([0, 1, 2, 0, 2])
|
||||
X = scipy.sparse.csc_matrix((data, row_idx, indptr), shape=(3, 2))
|
||||
assert tm.predictor_equal(xgb.DMatrix(X.tocsr()), xgb.DMatrix(X))
|
||||
|
||||
def test_coo(self):
|
||||
row = np.array([0, 2, 2, 0, 1, 2])
|
||||
col = np.array([0, 0, 1, 2, 2, 2])
|
||||
|
||||
Reference in New Issue
Block a user