Skip to content

Commit 72610f1

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

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

sklearn/datasets/_base.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
from os import environ, listdir, makedirs
1616
from os.path import expanduser, isdir, join, splitext
1717
from pathlib import Path
18+
from numbers import Integral
1819

1920
from ..preprocessing import scale
2021
from ..utils import Bunch
2122
from ..utils import check_random_state
2223
from ..utils import check_pandas_support
2324
from ..utils.fixes import _open_binary, _open_text, _read_text, _contents
24-
from ..utils._param_validation import validate_params
25+
from ..utils._param_validation import validate_params, Interval
2526

2627
import numpy as np
2728

@@ -826,6 +827,13 @@ def load_breast_cancer(*, return_X_y=False, as_frame=False):
826827
)
827828

828829

830+
@validate_params(
831+
{
832+
"n_class": [Interval(Integral, 1, 10, closed="both")],
833+
"return_X_y": ["boolean"],
834+
"as_frame": ["boolean"],
835+
}
836+
)
829837
def load_digits(*, n_class=10, return_X_y=False, as_frame=False):
830838
"""Load and return the digits dataset (classification).
831839

sklearn/tests/test_public_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def _check_function_param_validation(
132132
"sklearn.datasets.fetch_species_distributions",
133133
"sklearn.datasets.load_breast_cancer",
134134
"sklearn.datasets.load_diabetes",
135+
"sklearn.datasets.load_digits",
135136
"sklearn.datasets.load_iris",
136137
"sklearn.datasets.load_linnerud",
137138
"sklearn.datasets.load_svmlight_file",

0 commit comments

Comments
 (0)