def base_message()

in multiset_codec/rans.py [0:0]


def base_message(shape, randomize=False):
    """
    Returns a base ANS message of given shape. If randomize=True,
    populates the lower bits of the head with samples from a Bernoulli(1/2)
    distribution. The tail is empty.
    """
    assert shape and np.prod(shape), 'Shape must be an int > 0' \
                                     'or tuple with length > 0.'
    head = np.full(shape, rans_l, "uint64")
    if randomize:
        head += rng.integers(0, rans_l, size=shape, dtype='uint64')
    return head, ()