goulib.itertools2¶
additions to itertools standard library
Functions
|
Return running totals. |
|
|
|
generates all i,j pairs for i,j from 0-size |
|
|
|
range for floats or other types (numpy.arange without numpy) |
|
generate items corresponding to the n best values of key sort order |
|
Detect a cycle in iterable using Floyd "tortue hand hare" algorithm |
|
combinations_with_replacement('ABC', 2) --> AA AB AC BB BC CC same as combinations_with_replacement except it doesn't generate duplicates |
|
Compose two functions -> compose(f, g)(x) -> f(g(x)) |
|
generates (item,count) pairs by counting the number of consecutive items in iterable) |
|
Count unique elements |
|
|
|
|
|
extract keys from dic :param dic: dict source :param keys: iterable of dict keys :result: dict,dict : the first contains entries present in source, the second the remaining entries |
|
generate items in sorted iterable1 that are not in sorted iterable2 |
|
Drop n elements from iterable and return the rest |
|
makes sure iterable is sorted according to key |
|
generalizes enumerate to dicts :result: key,value pair for whatever iterable type |
|
Take an element from iterator every n elements |
|
like python.filter but returns 2 lists : - list of elements in iterable that satisfy condition - list of those that don't |
|
Return first item in iterable where f(item) == True. |
|
|
|
|
|
iterator to flatten (depth-first) structure |
|
Detect a cycle in iterable using Floyd "tortue hand hare" algorithm |
|
Make groups of 'n' elements from the iterable advancing 'step' elements on each iteration |
|
Cartesian product of sequences (recursive version) |
|
Do nothing and return the variable untouched |
|
iterates through items in iterable where f(item) == True. |
|
|
|
|
|
|
|
|
|
|
|
generates itersection of N iterables |
|
|
|
Like python.reduce but using iterators (a.k.a scanl) |
|
removes items from an iterable based on condition :param iterable: iterable . |
|
|
|
|
|
split iterable by separators or condition :param sep: value or function(item) returning True for items that separate :param include_sep: bool. |
|
|
|
After Haskell's iterate: apply function repeatedly. |
|
|
|
|
|
iterator over n values linearly interpolated between (and including) start and end numpy.linspace without numpy |
|
number of dimensions of a mutidimensional array, without numpy |
|
Like C++ std::next_permutation() but implemented as generator. |
|
|
|
|
|
count number of occurences of each item in a finite iterable |
|
iterates through consecutive pairs |
|
Cartesian product of (infinite) input iterables. |
|
|
|
|
|
return the index and value of iterable which exceed previous max |
|
|
|
|
|
|
|
removes items from an iterable based on condition :param iterable: iterable . |
|
|
|
|
|
shape of a mutidimensional array, without numpy |
|
|
|
|
|
sorts an "almost sorted" (infinite) iterable |
|
like https://docs.python.org/2/library/stdtypes.html#str.split, but for iterable :param sep: value or function(item) returning True for items that separate :param include_sep: bool. |
|
extract "sub-dictionary" :param d: dict :param keys: container of keys to extract: :result: dict: :see: http://stackoverflow.com/questions/5352546/best-way-to-extract-subset-of-key-value-pairs-from-python-dictionary-object/5352649#5352649 |
|
|
|
Get tails of a sequence |
|
|
|
Take an element from iterator every n elements |
|
|
|
tee or copy depending on type and goal |
|
generate unique elements, preserving order. |
Classes
|
Takes in an object that is iterable. |
|
iterator that keeps the last value |
Exceptions
|