Skip to content

Commit feb10b0

Browse files
committed
fix some tests
1 parent 7f80d78 commit feb10b0

17 files changed

+105
-79
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Set up Python
1616
uses: actions/setup-python@v5
1717
with:
18-
python-version: "3.12"
18+
python-version: "3.13"
1919

2020
- name: install tests dependencies
2121
run: python -m pip install tox

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: setup Python
1717
uses: actions/setup-python@v5
1818
with:
19-
python-version: "3.12"
19+
python-version: "3.13"
2020

2121
- name: install tests dependencies
2222
run: python -m pip install tox

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Set up Python
1515
uses: actions/setup-python@v5
1616
with:
17-
python-version: "3.12"
17+
python-version: "3.13"
1818

1919
- name: install tests dependencies
2020
run: python -m pip install tox

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ubuntu-22.04, macos-14, windows-2022]
15-
python-version: ["3.9", "3.12"]
15+
python-version: ["3.0", "3.13"]
1616

1717
steps:
1818
- uses: actions/checkout@v4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
*.coverage*
12
*.pyc
23
*.ipynb_checkpoints*
34
__pycache__

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ version: 2
99
build:
1010
os: ubuntu-22.04
1111
tools:
12-
python: "3.12"
12+
python: "3.13"
1313

1414
# Build documentation in the docs/ directory with Sphinx
1515
sphinx:

pyproject.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ authors = [
1919
{name = "Michele Ceriotti"}
2020
]
2121
readme = "README.rst"
22-
requires-python = ">=3.9"
22+
requires-python = ">=3.10"
2323
license = {text = "BSD-3-Clause"}
2424
classifiers = [
2525
"Development Status :: 4 - Beta",
@@ -75,9 +75,6 @@ include = [
7575
[tool.coverage.xml]
7676
output = 'tests/coverage.xml'
7777

78-
[tool.pytest.ini_options]
79-
testpaths = "tests"
80-
8178
[tool.isort]
8279
skip = "__init__.py"
8380
profile = "black"

src/skmatter/_selection.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -561,17 +561,15 @@ def score(self, X, y=None):
561561
562562
Parameters
563563
----------
564-
X : numpy.ndarray of shape [n_samples, n_features]
565-
The input samples.
564+
X : ignored
566565
y : ignored
567566
568567
Returns
569568
-------
570569
score : numpy.ndarray of (n_to_select_from_)
571570
:math:`\pi` importance for the given samples or features
572571
"""
573-
X, y = validate_data(self, X, y, reset=False)
574-
572+
validate_data(self, X, y, reset=False) # present for API consistency
575573
return self.pi_
576574

577575
def _init_greedy_search(self, X, y, n_to_select):
@@ -746,8 +744,7 @@ def score(self, X, y=None):
746744
score : numpy.ndarray of (n_to_select_from_)
747745
:math:`\pi` importance for the given samples or features
748746
"""
749-
X, y = validate_data(self, X, y, reset=False)
750-
747+
validate_data(self, X, y, reset=False) # present for API consistency
751748
return self.pi_
752749

753750
def _init_greedy_search(self, X, y, n_to_select):
@@ -941,8 +938,7 @@ def score(self, X, y=None):
941938
-------
942939
hausdorff : Hausdorff distances
943940
"""
944-
X, y = validate_data(self, X, y, reset=False)
945-
941+
validate_data(self, X, y, reset=False)
946942
return self.hausdorff_
947943

948944
def get_distance(self):
@@ -1079,15 +1075,16 @@ def __init__(
10791075
)
10801076

10811077
def fit(self, X, y=None, warm_start=False):
1082-
10831078
if self.mixing == 1.0:
10841079
raise ValueError(
1085-
"Mixing = 1.0 corresponds to traditional FPS."
1086-
"Please use the FPS class."
1080+
"Mixing = 1.0 corresponds to traditional FPS. Please use the FPS class."
10871081
)
10881082

10891083
return super().fit(X, y)
10901084

1085+
# docstring is inherited and set from the base class
1086+
fit.__doc__ = GreedySelector.fit.__doc__
1087+
10911088
def score(self, X, y=None):
10921089
"""Returns the Hausdorff distances of all samples to previous selections.
10931090
@@ -1104,8 +1101,7 @@ def score(self, X, y=None):
11041101
-------
11051102
hausdorff : Hausdorff distances
11061103
"""
1107-
X, y = validate_data(self, X, y, reset=False)
1108-
1104+
validate_data(self, X, y, reset=False)
11091105
return self.hausdorff_
11101106

11111107
def get_distance(self):

src/skmatter/decomposition/_kernel_pcovr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def score(self, X, y):
474474
"""
475475
check_is_fitted(self, ["pkt_", "X_fit_"])
476476

477-
X, y = validate_data(self, X, y, reset=False)
477+
X = validate_data(self, X, reset=False)
478478

479479
K_NN = self._get_kernel(self.X_fit_, self.X_fit_)
480480
K_VN = self._get_kernel(X, self.X_fit_)

src/skmatter/decomposition/_pcovr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from sklearn.decomposition._pca import _infer_dimension
1111
from sklearn.linear_model import LinearRegression, Ridge, RidgeCV
1212
from sklearn.linear_model._base import LinearModel
13-
from sklearn.utils import check_random_state
13+
from sklearn.utils import check_array, check_random_state
1414
from sklearn.utils._arpack import _init_arpack_v0
1515
from sklearn.utils.extmath import randomized_svd, stable_cumsum, svd_flip
1616
from sklearn.utils.validation import check_is_fitted, validate_data
@@ -585,7 +585,7 @@ def predict(self, X=None, T=None):
585585
X = validate_data(self, X, reset=False)
586586
return X @ self.pxy_
587587
else:
588-
T = validate_data(self, T, reset=False)
588+
T = check_array(T)
589589
return T @ self.pty_
590590

591591
def transform(self, X=None):

0 commit comments

Comments
 (0)