Skip to content

Commit 54e07cd

Browse files
committed
Test: Prediction for df with empty categoricals
1 parent 708f536 commit 54e07cd

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/test_dataprocessing.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_parsing_pandas(tmp_path):
2828
file.writelines(lines)
2929

3030
pandas_categorical = extract_pandas_traintime_categories(model_file)
31-
assert pandas_categorical is None
31+
assert pandas_categorical == []
3232
pandas_categorical = extract_pandas_traintime_categories(mod_model_file)
3333
assert pandas_categorical == [
3434
["a", "b", "c"],
@@ -106,3 +106,16 @@ def test_sliced_arrays():
106106
llvm_model.predict(sliced, n_jobs=4), lgbm_model.predict(sliced), decimal=13
107107
)
108108
return
109+
110+
111+
def test_pd_empty_categories():
112+
# this model has `pandas_categorical:null`
113+
llvm_model = Model(model_file="tests/models/tiniest_single_tree/model.txt")
114+
llvm_model.compile()
115+
lgbm_model = Booster(model_file="tests/models/tiniest_single_tree/model.txt")
116+
df = pd.DataFrame(
117+
{str(i): list(range(10)) for i in range(llvm_model.num_feature())}
118+
)
119+
np.testing.assert_almost_equal(
120+
llvm_model.predict(df), lgbm_model.predict(df), decimal=13
121+
)

0 commit comments

Comments
 (0)