Skip to content

Lyndon Words

log_signatures_pytorch.lyndon_words.logsigdim_words(width, depth)

Dimension of the truncated log-signature in the Lyndon "words" basis.

Source code in src/log_signatures_pytorch/lyndon_words.py
def logsigdim_words(width: int, depth: int) -> int:
    """Dimension of the truncated log-signature in the Lyndon \"words\" basis."""
    return len(lyndon_words(width, depth))

log_signatures_pytorch.lyndon_words.logsigkeys_words(width, depth)

Human-readable labels for the Lyndon "words" basis (Signatory style).

Source code in src/log_signatures_pytorch/lyndon_words.py
def logsigkeys_words(width: int, depth: int) -> List[str]:
    """Human-readable labels for the Lyndon \"words\" basis (Signatory style)."""

    def _to_str(word: WordsBasisElement) -> str:
        return ",".join(str(x) for x in word)

    return [_to_str(word) for word in lyndon_words(width, depth)]

log_signatures_pytorch.lyndon_words.lyndon_words(width, depth) cached

Lyndon words up to depth in Signatory-compatible ordering.

Source code in src/log_signatures_pytorch/lyndon_words.py
@lru_cache(maxsize=None)
def lyndon_words(width: int, depth: int) -> Tuple[WordsBasisElement, ...]:
    """Lyndon words up to ``depth`` in Signatory-compatible ordering."""
    if width < 1:
        raise ValueError("width must be >= 1")
    if depth < 1:
        raise ValueError("depth must be >= 1")

    words: List[WordsBasisElement] = []
    for length in range(1, depth + 1):
        words.extend(_lyndon_fixed_length(width, length))
    return tuple(words)