def split_sequence_extended_to_weights(sequence, weights, overhang=True): '''Split sequence extended to weights. .. container:: example **Example 1.** Split sequence extended to weights with overhang: :: >>> sequencetools.split_sequence_extended_to_weights( ... [1, 2, 3, 4, 5], [7, 7, 7], overhang=True) [[1, 2, 3, 1], [3, 4], [1, 1, 2, 3], [4, 5]] .. container:: example **Example 2.** Split sequence extended to weights without overhang: :: >>> sequencetools.split_sequence_extended_to_weights( ... [1, 2, 3, 4, 5], [7, 7, 7], overhang=False) [[1, 2, 3, 1], [3, 4], [1, 1, 2, 3]] Returns sequence of sequence objects. ''' from abjad.tools import sequencetools n = int(math.ceil(float(mathtools.weight(weights)) / mathtools.weight(sequence))) sequence = sequencetools.repeat_sequence_n_times(sequence, n) return sequencetools.split_sequence_by_weights(sequence, weights, cyclic=False, overhang=overhang)
def partition_sequence_extended_to_counts(sequence, counts, overhang=True): """Partition sequence extended to counts. .. container:: example **Example 1.** Partition sequence extended to counts with overhang: :: >>> sequencetools.partition_sequence_extended_to_counts( ... (1, 2, 3, 4), ... (6, 6, 6), ... overhang=True, ... ) [(1, 2, 3, 4, 1, 2), (3, 4, 1, 2, 3, 4), (1, 2, 3, 4, 1, 2), (3, 4)] .. container:: example **Example 2.** Partition sequence extended to coutns without overhang: :: >>> sequencetools.partition_sequence_extended_to_counts( ... (1, 2, 3, 4), ... (6, 6, 6), ... overhang=False, ... ) [(1, 2, 3, 4, 1, 2), (3, 4, 1, 2, 3, 4), (1, 2, 3, 4, 1, 2)] Returns sequence of sequence objects. """ from abjad.tools import sequencetools n = int(math.ceil(float(sum(counts)) / len(sequence))) sequence = sequencetools.repeat_sequence_n_times(sequence, n) return sequencetools.partition_sequence_by_counts(sequence, counts, cyclic=False, overhang=overhang)