Module mimir.utils

utils.py This module provides utility functions.

Environment Variables: MIMIR_CACHE_PATH: The path to the cache directory. This should be set in the environment. MIMIR_DATA_SOURCE: The data source for the MIMIR project. This should be set in the environment.

Functions

def fix_seed(seed: int = 0)
Expand source code
def fix_seed(seed: int = 0):
    """
    Fix seed for reproducibility.

    Parameters:
        seed (int): The seed to set. Default is 0.
    """
    ch.manual_seed(seed)
    np.random.seed(seed)
    random.seed(seed)

Fix seed for reproducibility.

Parameters

seed (int): The seed to set. Default is 0.

def get_cache_path()
Expand source code
def get_cache_path():
    """
    Get path to cache directory.
    Returns:
        str: path to cache directory

    Raises:
        ValueError: If the MIMIR_CACHE_PATH environment variable is not set.
    """
    if CACHE_PATH is None:
        raise ValueError('MIMIR_CACHE_PATH environment variable not set')
    return CACHE_PATH

Get path to cache directory.

Returns

str
path to cache directory

Raises

ValueError
If the MIMIR_CACHE_PATH environment variable is not set.
def get_data_source()
Expand source code
def get_data_source():
    """
    Get path to data source directory.
    Returns:
        str: path to data source directory

    Raises:
        ValueError: If the MIMIR_DATA_SOURCE environment variable is not set.
    """
    if DATA_SOURCE is None:
        raise ValueError('MIMIR_DATA_SOURCE environment variable not set')
    return DATA_SOURCE

Get path to data source directory.

Returns

str
path to data source directory

Raises

ValueError
If the MIMIR_DATA_SOURCE environment variable is not set.