Fix TypeError of customized kfold method which needs 'y' (#1450)

This commit is contained in:
Li Jiang
2025-08-02 08:05:50 +08:00
committed by GitHub
parent 2d16089529
commit be81a76da9
2 changed files with 7 additions and 4 deletions

View File

@@ -35,7 +35,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-2019]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
@@ -91,12 +91,12 @@ jobs:
- name: Test with pytest
if: matrix.python-version != '3.10'
run: |
pytest test/
pytest test/ --ignore=test/autogen
- name: Coverage
if: matrix.python-version == '3.10'
run: |
pip install coverage
coverage run -a -m pytest test
coverage run -a -m pytest test --ignore=test/autogen
coverage xml
- name: Upload coverage to Codecov
if: matrix.python-version == '3.10'

View File

@@ -746,7 +746,10 @@ class GenericTask(Task):
elif isinstance(kf, TimeSeriesSplit):
kf = kf.split(X_train_split, y_train_split)
else:
kf = kf.split(X_train_split)
try:
kf = kf.split(X_train_split)
except TypeError:
kf = kf.split(X_train_split, y_train_split)
for train_index, val_index in kf:
if shuffle: