Skip to content

Registry API

oeis_code.registry

Registry mapping OEIS identifiers to their sequence functions.

register(seq_id)

Return a decorator that registers a sequence under seq_id.

Parameters

seq_id : str The OEIS sequence identifier (e.g., 'A000045').

Returns

Callable[[Callable[..., Any]], Callable[..., Any]] The decorator, which stores the decorated function in registry and returns it unchanged.

Source code in src/oeis_code/registry.py
def register(
    seq_id: str,
) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
    """
    Return a decorator that registers a sequence under ``seq_id``.

    Parameters
    ----------
    seq_id : str
        The OEIS sequence identifier (e.g., 'A000045').

    Returns
    -------
    Callable[[Callable[..., Any]], Callable[..., Any]]
        The decorator, which stores the decorated function in
        ``registry`` and returns it unchanged.
    """

    def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
        """Register ``func`` under ``seq_id`` and return it."""
        registry[seq_id] = func
        return func

    return decorator