| 302 | bst.predict(dtrain) |
| 303 | |
| 304 | def test_unknown_data(self): |
| 305 | class Data: |
| 306 | pass |
| 307 | |
| 308 | with pytest.raises(TypeError): |
| 309 | with pytest.warns(UserWarning): |
| 310 | d = Data() |
| 311 | xgb.DMatrix(d) |
| 312 | |
| 313 | from scipy import sparse |
| 314 | |
| 315 | rng = np.random.RandomState(1994) |
| 316 | X = rng.rand(10, 10) |
| 317 | y = rng.rand(10) |
| 318 | X = sparse.dok_matrix(X) |
| 319 | with pytest.warns(UserWarning, match="dok_matrix"): |
| 320 | Xy = xgb.DMatrix(X, y) |
| 321 | assert Xy.num_row() == 10 |
| 322 | assert Xy.num_col() == 10 |
| 323 | |
| 324 | @pytest.mark.skipif(**tm.no_pandas()) |
| 325 | def test_np_categorical(self): |