Skip to content

Commit 75d1dea

Browse files
MAINT Parameters validation for sklearn.datasets.load_sample_image (#26226)
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com>
1 parent a43640f commit 75d1dea

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

sklearn/datasets/_base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,11 @@ def load_sample_images():
12751275
return Bunch(images=images, filenames=filenames, DESCR=descr)
12761276

12771277

1278+
@validate_params(
1279+
{
1280+
"image_name": [StrOptions({"china.jpg", "flower.jpg"})],
1281+
}
1282+
)
12781283
def load_sample_image(image_name):
12791284
"""Load the numpy array of a single sample image.
12801285

sklearn/datasets/tests/test_base.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,6 @@ def test_load_sample_image():
222222
warnings.warn("Could not load sample images, PIL is not available.")
223223

224224

225-
def test_load_missing_sample_image_error():
226-
pytest.importorskip("PIL")
227-
with pytest.raises(AttributeError):
228-
load_sample_image("blop.jpg")
229-
230-
231225
def test_load_diabetes_raw():
232226
"""Test to check that we load a scaled version by default but that we can
233227
get an unscaled version when setting `scaled=False`."""

sklearn/tests/test_public_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def _check_function_param_validation(
138138
"sklearn.datasets.load_files",
139139
"sklearn.datasets.load_iris",
140140
"sklearn.datasets.load_linnerud",
141+
"sklearn.datasets.load_sample_image",
141142
"sklearn.datasets.load_svmlight_file",
142143
"sklearn.datasets.load_svmlight_files",
143144
"sklearn.datasets.load_wine",

0 commit comments

Comments
 (0)