Skip to content

Commit 71ff1fe

Browse files
authored
FIX Delayer to deal with recent sklearn versions (#34)
* FIX inherit transformer_tags from TransformerMixin for Delayer * Validate data following sklearn's suggestion * MNT do not run tests on EOL python
1 parent f8bb9cf commit 71ff1fe

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

.github/workflows/run_tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
14+
python-version: [3.9, "3.10", "3.11"]
1515
max-parallel: 5
16+
fail-fast: false
1617

1718
steps:
1819
- uses: actions/checkout@v4

voxelwise_tutorials/delayer.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import numpy as np
22
from sklearn.base import BaseEstimator, TransformerMixin
3-
from sklearn.utils.validation import check_is_fitted, check_array
3+
from sklearn.utils.validation import check_is_fitted, validate_data
44

55

6-
class Delayer(BaseEstimator, TransformerMixin):
6+
class Delayer(TransformerMixin, BaseEstimator):
77
"""Scikit-learn Transformer to add delays to features.
88
99
This assumes that the samples are ordered in time.
@@ -50,7 +50,7 @@ def fit(self, X, y=None):
5050
-------
5151
self : returns an instance of self.
5252
"""
53-
X = self._validate_data(X, dtype='numeric')
53+
X = validate_data(self, X, dtype='numeric')
5454
self.n_features_in_ = X.shape[1]
5555
return self
5656

@@ -68,12 +68,9 @@ def transform(self, X):
6868
Transformed data.
6969
"""
7070
check_is_fitted(self)
71-
X = check_array(X, copy=True)
71+
X = validate_data(self, X, reset=False, copy=True)
7272

7373
n_samples, n_features = X.shape
74-
if n_features != self.n_features_in_:
75-
raise ValueError(
76-
'Different number of features in X than during fit.')
7774

7875
if self.delays is None:
7976
return X

0 commit comments

Comments
 (0)