Skip to content

MAINT Parameters validation for sklearn.datasets.get_data_home #26260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sklearn/datasets/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
RemoteFileMetadata = namedtuple("RemoteFileMetadata", ["filename", "url", "checksum"])


@validate_params(
{
"data_home": [str, os.PathLike, None],
}
)
def get_data_home(data_home=None) -> str:
"""Return the path of the scikit-learn data directory.

Expand All @@ -58,7 +63,7 @@ def get_data_home(data_home=None) -> str:

Returns
-------
data_home: str
data_home: str or path-like, default=None
The path to scikit-learn data directory.
"""
if data_home is None:
Expand Down
2 changes: 1 addition & 1 deletion sklearn/datasets/_openml.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ def fetch_openml(
data_home = None
else:
data_home = get_data_home(data_home=data_home)
data_home = join(data_home, "openml")
data_home = join(str(data_home), "openml")

# check valid function arguments. data_id XOR (name, version) should be
# provided
Expand Down
1 change: 1 addition & 0 deletions sklearn/tests/test_public_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def _check_function_param_validation(
"sklearn.datasets.fetch_olivetti_faces",
"sklearn.datasets.fetch_rcv1",
"sklearn.datasets.fetch_species_distributions",
"sklearn.datasets.get_data_home",
"sklearn.datasets.load_breast_cancer",
"sklearn.datasets.load_diabetes",
"sklearn.datasets.load_digits",
Expand Down