8000 DOC add docstring example for clear_data_home and fetch_covtype by Dutta-SD · Pull Request #28027 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

DOC add docstring example for clear_data_home and fetch_covtype #28027

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 8 commits into from
Jan 12, 2024
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
12 changes: 9 additions & 3 deletions sklearn/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,16 @@ def pytest_collection_modifyitems(config, items):
datasets_to_download = set()

for item in items:
if not hasattr(item, "fixturenames"):
if isinstance(item, DoctestItem) and "fetch_" in item.name:
fetcher_function_name = item.name.split(".")[-1]
dataset_fetchers_key = f"{fetcher_function_name}_fxt"
dataset_to_fetch = set([dataset_fetchers_key]) & dataset_features_set
elif not hasattr(item, "fixturenames"):
continue
item_fixtures = set(item.fixturenames)
dataset_to_fetch = item_fixtures & dataset_features_set
else:
item_fixtures = set(item.fixturenames)
dataset_to_fetch = item_fixtures & dataset_features_set

if not dataset_to_fetch:
continue

Expand Down
5 changes: 5 additions & 0 deletions sklearn/datasets/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ def clear_data_home(data_home=None):
data_home : str or path-like, default=None
The path to scikit-learn data directory. If `None`, the default path
is `~/scikit_learn_data`.

Examples
----------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though the PR has already been merged I think it's worth mentioning that the underline length is wrong, causing numpydoc to raise warning during doc build.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I will make a quick PR. Thanks.

>>> from sklearn.datasets import clear_data_home
>>> clear_data_home() # doctest: +SKIP
"""
data_home = get_data_home(data_home)
shutil.rmtree(data_home)
Expand Down
12 changes: 12 additions & 0 deletions sklearn/datasets/_covtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ def fetch_covtype(
ndarray of shape (n_samples,) containing the target samples.

.. versionadded:: 0.20

Examples
--------
>>> from sklearn.datasets import fetch_covtype
>>> cov_type = fetch_covtype()
>>> cov_type.data.shape
(581012, 54)
>>> cov_type.target.shape
(581012,)
>>> # Let's check the 4 first feature names
>>> cov_type.feature_names[:4]
['Elevation', 'Aspect', 'Slope', 'Horizontal_Distance_To_Hydrology']
"""
data_home = get_data_home(data_home=data_home)
covtype_dir = join(data_home, "covertype")
Expand Down
0