Skip to content

get_func

Module to get read functions.

ReadFunc #

Bases: Protocol

Protocol for type hinting read functions.

Source code in src/careamics/file_io/read/get_func.py
class ReadFunc(Protocol):
    """Protocol for type hinting read functions."""

    def __call__(self, file_path: Path, *args, **kwargs) -> NDArray:
        """
        Type hinted callables must match this function signature (not including self).

        Parameters
        ----------
        file_path : pathlib.Path
            Path to file.
        *args
            Other positional arguments.
        **kwargs
            Other keyword arguments.
        """

__call__(file_path, *args, **kwargs) #

Type hinted callables must match this function signature (not including self).

Parameters:

Name Type Description Default
file_path Path

Path to file.

required
*args

Other positional arguments.

()
**kwargs

Other keyword arguments.

{}
Source code in src/careamics/file_io/read/get_func.py
def __call__(self, file_path: Path, *args, **kwargs) -> NDArray:
    """
    Type hinted callables must match this function signature (not including self).

    Parameters
    ----------
    file_path : pathlib.Path
        Path to file.
    *args
        Other positional arguments.
    **kwargs
        Other keyword arguments.
    """

get_read_func(data_type) #

Get the read function for the data type.

Parameters:

Name Type Description Default
data_type SupportedData

Data type.

required

Returns:

Type Description
callable

Read function.

Source code in src/careamics/file_io/read/get_func.py
def get_read_func(data_type: Union[str, SupportedData]) -> Callable:
    """
    Get the read function for the data type.

    Parameters
    ----------
    data_type : SupportedData
        Data type.

    Returns
    -------
    callable
        Read function.
    """
    if data_type in READ_FUNCS:
        data_type = SupportedData(data_type)  # mypy complaining about dict key type
        return READ_FUNCS[data_type]
    else:
        raise NotImplementedError(f"Data type '{data_type}' is not supported.")