polymerist.genutils.sequences

Tools for working with ordered sequences (i.e. collections of elements with definite length and order)

Submodules

Attributes

T

S

Functions

is_unique(→ bool)

Whether or not a Sequence contains repeating items

int_complement(→ Generator[int, None, None])

Generate ordered non-negative integers which don't appear in a sequence of integers

pad_sequence(→ list[Union[T, S]])

Pad a given list with a particular value

cycle_items(→ list[T])

Cyclically shift all items in a sequence over by the target number of indices

Package Contents

polymerist.genutils.sequences.T
polymerist.genutils.sequences.S
polymerist.genutils.sequences.is_unique(seq: Sequence) bool[source]

Whether or not a Sequence contains repeating items

polymerist.genutils.sequences.int_complement(integers: Sequence[int], bounded: bool = False) Generator[int, None, None][source]

Generate ordered non-negative integers which don’t appear in a sequence of integers

polymerist.genutils.sequences.pad_sequence(target_list: Sequence[T], to_length: int, pad_value: S = 0, from_left: bool = False) list[T | S][source]

Pad a given list with a particular value

polymerist.genutils.sequences.cycle_items(seq: Sequence[T], places: int = 1) list[T][source]

Cyclically shift all items in a sequence over by the target number of indices By default shifts right, but can also move to left with negative “places” argument

Examples:

cycle_items([1,2,3,4], 2) -> [3,4,1,2] cycle_items([1,2,3,4], -1) -> [4,1,2,3]