partition_sequence_by_ratio_of_weights

sequencetools.partition_sequence_by_ratio_of_weights(sequence, weights)

Partitions sequence by ratio of weights.

>>> sequencetools.partition_sequence_by_ratio_of_weights(
...     [1] * 10, [1, 1, 1])
[[1, 1, 1], [1, 1, 1, 1], [1, 1, 1]]
>>> sequencetools.partition_sequence_by_ratio_of_weights(
...     [1] * 10, [1, 1, 1, 1])
[[1, 1, 1], [1, 1], [1, 1, 1], [1, 1]]
>>> sequencetools.partition_sequence_by_ratio_of_weights(
...     [1] * 10, [2, 2, 3])
[[1, 1, 1], [1, 1, 1], [1, 1, 1, 1]]
>>> sequencetools.partition_sequence_by_ratio_of_weights(
...     [1] * 10, [3, 2, 2])
[[1, 1, 1, 1], [1, 1, 1], [1, 1, 1]]
>>> sequencetools.partition_sequence_by_ratio_of_weights(
...     [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2], [1, 1])
[[1, 1, 1, 1, 1, 1, 2, 2], [2, 2, 2, 2]]
>>> sequencetools.partition_sequence_by_ratio_of_weights(
...     [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2], [1, 1, 1])
[[1, 1, 1, 1, 1, 1], [2, 2, 2], [2, 2, 2]]

Weights of parts of returned list equal weights_ratio proportions with some rounding magic.

Returns list of lists.