bmcfee / muda

A library for augmenting annotated audio data
ISC License
230 stars 33 forks source link

Deformation union #50

Closed bmcfee closed 7 years ago

bmcfee commented 7 years ago

The pipeline object allows for cascading of multiple deformers into a single chain.

Sometimes, we just want to apply a set of deformations independently, but there's no direct way to do that currently.

It would be easy to implement something analogous to a sklearn feature union that does round-robin sampling from each deformer.

bmcfee commented 7 years ago

From the itertools recipes page:


def roundrobin(*iterables):
    "roundrobin('ABC', 'D', 'EF') --> A D E B F C"
    # Recipe credited to George Sakkis
    pending = len(iterables)
    nexts = cycle(iter(it).next for it in iterables)
    while pending:
        try:
            for next in nexts:
                yield next()
        except StopIteration:
            pending -= 1
            nexts = cycle(islice(nexts, pending))