Skip to content

get_data_home

yohou.datasets._fetchers.get_data_home(data_home=None)

Return the path of the yohou data directory.

By default the data directory is set to a folder named yohou_data in the user home folder. Alternatively, it can be set programmatically by giving an explicit folder path. The YOHOU_DATA environment variable has the same effect. If the folder does not already exist, it is automatically created.

Parameters

Name Type Description Default
data_home str, PathLike, or None

The path to the data directory. If None, the default path is ~/yohou_data.

None

Returns

Type Description
str

The path to the data directory.

See Also

Source Code

Show/Hide source
def get_data_home(data_home: str | os.PathLike | None = None) -> str:
    """Return the path of the yohou data directory.

    By default the data directory is set to a folder named ``yohou_data``
    in the user home folder. Alternatively, it can be set programmatically
    by giving an explicit folder path. The ``YOHOU_DATA`` environment
    variable has the same effect. If the folder does not already exist,
    it is automatically created.

    Parameters
    ----------
    data_home : str, PathLike, or None
        The path to the data directory. If ``None``, the default path
        is ``~/yohou_data``.

    Returns
    -------
    str
        The path to the data directory.

    See Also
    --------
    - [`clear_data_home`][yohou.datasets._fetchers.clear_data_home] : Delete all cached datasets.

    """
    if data_home is None:
        data_home = os.environ.get("YOHOU_DATA", os.path.join("~", "yohou_data"))
    data_home = os.path.expanduser(str(data_home))
    os.makedirs(data_home, exist_ok=True)
    return data_home