def sig_dim(alphabet_size, depth):
    """Calculates the number of terms in a signature of depth :depth: over an alphabet of size :alphabet_size:."""
    return int(alphabet_size * (1 - alphabet_size ** depth) / (1 - alphabet_size))
    # == sum(alphabet_size ** i for i in range(1, depth + 1)) (geometric sum formula)