Fix with None input. (#10052)
This commit is contained in:
@@ -202,7 +202,10 @@ class TestFromCupy:
|
||||
n = 100
|
||||
X = cp.random.random((n, 2))
|
||||
m = xgb.QuantileDMatrix(X.toDlpack())
|
||||
with pytest.raises(xgb.core.XGBoostError):
|
||||
|
||||
with pytest.raises(
|
||||
xgb.core.XGBoostError, match="Slicing DMatrix is not supported"
|
||||
):
|
||||
m.slice(rindex=[0, 1, 2])
|
||||
|
||||
@pytest.mark.skipif(**tm.no_cupy())
|
||||
|
||||
@@ -1456,3 +1456,16 @@ def test_intercept() -> None:
|
||||
result = reg.intercept_
|
||||
assert result.dtype == np.float32
|
||||
assert result[0] < 0.5
|
||||
|
||||
|
||||
def test_fit_none() -> None:
|
||||
with pytest.raises(TypeError, match="NoneType"):
|
||||
xgb.XGBClassifier().fit(None, [0, 1])
|
||||
|
||||
X = rng.normal(size=4).reshape(2, 2)
|
||||
|
||||
with pytest.raises(ValueError, match="Invalid classes"):
|
||||
xgb.XGBClassifier().fit(X, None)
|
||||
|
||||
with pytest.raises(ValueError, match="labels"):
|
||||
xgb.XGBRegressor().fit(X, None)
|
||||
|
||||
Reference in New Issue
Block a user