[breaking] Remove support for single string feature info. (#9401)

- Input must be a sequence of strings.
- Improve validation error message.
This commit is contained in:
Jiaming Yuan
2023-07-24 11:06:30 +08:00
committed by GitHub
parent 275da176ba
commit 01e00efc53
2 changed files with 90 additions and 104 deletions

View File

@@ -219,8 +219,8 @@ class TestDMatrix:
assert dm.slice([0, 1]).num_col() == dm.num_col()
assert dm.slice([0, 1]).feature_names == dm.feature_names
dm.feature_types = 'q'
assert dm.feature_types == list('qqqqq')
with pytest.raises(ValueError, match=r"Duplicates found: \['bar'\]"):
dm.feature_names = ["bar"] * (data.shape[1] - 2) + ["a", "b"]
dm.feature_types = list('qiqiq')
assert dm.feature_types == list('qiqiq')
@@ -230,6 +230,7 @@ class TestDMatrix:
# reset
dm.feature_names = None
dm.feature_types = None
assert dm.feature_names is None
assert dm.feature_types is None