Skip to content

Commit 413b63c

Browse files
Fix ruff lint and bitwise XOR on float32 in indicator test
Remove blank line between import groups (ruff check) and cast float32 slices to int32 before applying bitwise XOR to fix TypeError on numpy versions that enforce safe casting.
1 parent 80a4e59 commit 413b63c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tests/python/test_parse_tree.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import numpy as np
22
import pytest
3-
43
import xgboost as xgb
54
from xgboost import testing as tm
65
from xgboost.testing.parse_tree import (
@@ -60,7 +59,9 @@ def test_tree_to_df_indicator(self, tmp_path) -> None:
6059
n_samples = 200
6160
n_features = 5
6261
X = rng.randint(0, 2, size=(n_samples, n_features)).astype(np.float32)
63-
y = (X[:, 0] ^ X[:, 1]).astype(np.float32)
62+
y = (X[:, 0].astype(np.int32) ^ X[:, 1].astype(np.int32)).astype(
63+
np.float32
64+
)
6465
dtrain = xgb.DMatrix(X, label=y)
6566

6667
# Create a feature map with indicator type 'i'

0 commit comments

Comments
 (0)