Return after <rounds> passes through a cycled iterable.
16869
def round_controlled(cycled_iterable, rounds=1):
    """"""
    round_start = None
    rounds_completed = 0

    for item in cycled_iterable:
        if round_start is None:
            round_start = item
        elif item == round_start:
            rounds_completed += 1

        if rounds_completed == rounds:
            return

        yield item
354658
def frange(start, stop, step, precision):
    """"""
    value = start
    while round(value, precision) < stop:
        yield round(value, precision)
        value += step
400227
def item_after(self, item):
        
        next_iter = self._next_iter_for(item)
        if next_iter is not None:
            return self._object_at_iter(next_iter)
892562
def actually_flatten(iterable):
    """"""
    remainder = iter(iterable)
    while True:
        first = next(remainder)  # pylint: disable=R1708
        # Python 2/3 compat
        is_iter = isinstance(first, collections.Iterable)
        try:
            basestring
        except NameError:
            basestring = str  # pylint: disable=W0622

        if is_py3() and is_iter and not_a_string(first):
            remainder = IT.chain(first, remainder)
        elif (not is_py3()) and is_iter and not isinstance(first, basestring):
            remainder = IT.chain(first, remainder)
        else:
            yield polite_string(first)
480602
def next(self):
        """"""
        self._parse_block()
        if self._remaining > 0:
            self._remaining -= 1
        return six.next(self._iter_rows)
1266254
def this_and_prev(iterable):
    """"""
    try:
        item = next(iterable)
        while True:
            next_item = next(iterable)
            yield item, next_item
            item = next_item
    except StopIteration:
        return
524354
def value_after(self, x):
        """"""

        try:
            try:
                i = self.all.index(x)
            except ValueError:
                return None

            return self.all[i + 1]

        except IndexError:
            return None
695038
def transition(value, maximum, start, end):
    
    return round(start + (end - start) * value / maximum, 2)
501797
def drain(iterable):
    
    if getattr(iterable, "popleft", False):
        def next_item(coll):
            return coll.popleft()
    elif getattr(iterable, "popitem", False):
        def next_item(coll):
            return coll.popitem()
    else:
        def next_item(coll):
            return coll.pop()

    while True:
        try:
            yield next_item(iterable)
        except (IndexError, KeyError):
            raise StopIteration
773572
def just(*args):
    ''' 
    '''
    assert len(args) >= 1, 'generators.just needs at least one arg'

    if len(args) == 1: # if only one arg is given
        try:
            # try to cycle in a set for iteration speedup
            return cycle(set(args))
        except:
            # revert to cycling args as a tuple
            return cycle(args)
    else:
        return cycle({args})
147836
def ffill(iterable):
    
    it = iter(iterable)
    previous = next(it)
    yield previous
    for e in it:
        if e is None:
            yield previous
        else:
            previous = e
            yield e
659117
def _postrun(cls, span, obj, **kwargs):
        
        for key, value in ResultSchema().dump(obj.result).items():
            if isinstance(value, dict):
                try:
                    flat_data = cls.filter_keys(
                        cls.fix_additional_fields(value)
                    )
                    span.set_tag("result.{}".format(key), json.dumps(flat_data))
                except Exception:
                    span.set_tag("result.{}".format(key), "N/A")
            elif isinstance(value, (list, tuple)):
                try:
                    span.set_tag("result.{}".format(key), json.dumps(value))
                except Exception:
                    try:
                        span.set_tag("result.{}".format(key), value)
                    except Exception:
                        span.set_tag("result.{}".format(key), "N/A")
            else:
                span.set_tag("result.{}".format(key), value)
463307
def peekiter(iterable):
    """"""
    it = iter(iterable)
    one = next(it)

    def gen():
        """Generator that returns first and proxy other items from source"""
        yield one
        while True:
            yield next(it)
    return (one, gen())
1347584
def after(self, after):
        
        if after is not None and len(after) > 32:
            raise ValueError("Invalid value for `after`, length must be less than or equal to `32`")
        if after is not None and len(after) < 32:
            raise ValueError("Invalid value for `after`, length must be greater than or equal to `32`")

        self._after = after
1257696
def run_sequential(self):
        
        try:
            result = self.empty_result(*self.context)

            for obj in self.iterable:
                r = self.compute(obj, *self.context)
                result = self.process_result(r, result)
                self.progress.update(1)

                # Short-circuited?
                if self.done:
                    break
        except Exception as e:
            raise e
        finally:
            self.progress.close()

        return result
955760
def cycle(self, *args):
        """"""
        if not args:
            raise TypeError('no items for cycling given')
        return args[self.index0 % len(args)]
859010
def after_match(self, func, full_fallback=False):
        
        iterator = iter(self)
        for item in iterator:
            if func(item):
                return iterator
        if full_fallback:
            iterator = iter(self)
        return iterator