Skip to content

datasets

Functions to locate the example datasets used by the pathpyG tutorials.

example_data

Return a local path or a URL for one of the example datasets in docs/data.

Parameters:

Name Type Description Default
name str

File name of the dataset, e.g. temporal_clusters.tedges.

required

Returns:

Type Description
str

Either the path of a local copy of the dataset or a URL from which it can be read.

Source code in src/pathpyG/io/datasets.py
def example_data(name: str) -> str:
    """Return a local path or a URL for one of the example datasets in `docs/data`.

    Args:
        name: File name of the dataset, e.g. `temporal_clusters.tedges`.

    Returns:
        Either the path of a local copy of the dataset or a URL from which it can be read.
    """
    local = _EXAMPLE_DATA_DIR / name
    if local.is_file():
        logger.info(f"Reading example dataset from local path {local}")
        return str(local)

    url = EXAMPLE_DATA_URL + name
    logger.info(f"No local copy of {name} found, reading example dataset from {url}")
    return url