lazy_itertools Module

Itertools module “decorated” replica, where all outputs are Stream instances

Summary of module contents:

Name Description
chain This is a StrategyDict instance object called chain. Strategies stored: 2.
izip This is a StrategyDict instance object called izip. Strategies stored: 2.
tee Tee or “T” copy to help working with Stream instances as well as with numbers.
accumulate This is a StrategyDict instance object called accumulate. Strategies stored: 3.
repeat repeat(object [,times]) -> create an iterator which returns the object for the specified number of times. If not specified, returns the object endlessly.
takewhile takewhile(predicate, iterable) –> takewhile object
islice islice(iterable, stop) –> islice object islice(iterable, start, stop[, step]) –> islice object
cycle cycle(iterable) –> cycle object
_tee_dataobject Data container common to multiple tee objects.
product product(*iterables, repeat=1) –> product object
starmap starmap(function, sequence) –> starmap object
compress compress(data, selectors) –> iterator over selected data
ifilterfalse filterfalse(function or None, sequence) –> filterfalse object
combinations_with_replacement combinations_with_replacement(iterable, r) –> combinations_with_replacement object
permutations permutations(iterable[, r]) –> permutations object
_grouper <function _grouper at 0x7fb6b9fcad08>
dropwhile dropwhile(predicate, iterable) –> dropwhile object
izip_longest zip_longest(iter1 [,iter2 [...]], [fillvalue=None]) –> zip_longest object
groupby groupby(iterable[, keyfunc]) -> create an iterator which returns (key, sub-iterator) grouped by each value of key(value).
combinations combinations(iterable, r) –> combinations object
_tee Iterator wrapped to make it copyable
count count(start=0, step=1) –> count object
BuiltinImporter Meta path import for built-in modules.
imap map(func, *iterables) –> map object
ifilter filter(function or None, iterable) –> filter object
tee(data, n=2)[source]

Tee or “T” copy to help working with Stream instances as well as with numbers.

Parameters:
  • data – Input to be copied. Can be anything.
  • n – Size of returned tuple. Defaults to 2.
Returns:

Tuple of n independent Stream instances, if the input is a Stream or an iterator, otherwise a tuple with n times the same object.

See also

thub
use Stream instances almost like constants in your equations.
repeat(object[, times]) → create an iterator which returns the object

for the specified number of times. If not specified, returns the object endlessly.

takewhile()

takewhile(predicate, iterable) –> takewhile object

Return successive entries from an iterable as long as the predicate evaluates to true for each entry.

islice()

islice(iterable, stop) –> islice object islice(iterable, start, stop[, step]) –> islice object

Return an iterator whose next() method returns selected values from an iterable. If start is specified, will skip all preceding elements; otherwise, start defaults to zero. Step defaults to one. If specified as another value, step determines how many values are skipped between successive calls. Works like a slice() on a list but returns an iterator.

cycle()

cycle(iterable) –> cycle object

Return elements from the iterable until it is exhausted. Then repeat the sequence indefinitely.

_tee_dataobject()

Data container common to multiple tee objects.

product()

product(*iterables, repeat=1) –> product object

Cartesian product of input iterables. Equivalent to nested for-loops.

For example, product(A, B) returns the same as: ((x,y) for x in A for y in B). The leftmost iterators are in the outermost for-loop, so the output tuples cycle in a manner similar to an odometer (with the rightmost element changing on every iteration).

To compute the product of an iterable with itself, specify the number of repetitions with the optional repeat keyword argument. For example, product(A, repeat=4) means the same as product(A, A, A, A).

product(‘ab’, range(3)) –> (‘a’,0) (‘a’,1) (‘a’,2) (‘b’,0) (‘b’,1) (‘b’,2) product((0,1), (0,1), (0,1)) –> (0,0,0) (0,0,1) (0,1,0) (0,1,1) (1,0,0) ...

starmap()

starmap(function, sequence) –> starmap object

Return an iterator whose values are returned from the function evaluated with an argument tuple taken from the given sequence.

compress()

compress(data, selectors) –> iterator over selected data

Return data elements corresponding to true selector elements. Forms a shorter iterator from selected data elements using the selectors to choose the data elements.

ifilterfalse()

filterfalse(function or None, sequence) –> filterfalse object

Return those items of sequence for which function(item) is false. If function is None, return the items that are false.

combinations_with_replacement()

combinations_with_replacement(iterable, r) –> combinations_with_replacement object

Return successive r-length combinations of elements in the iterable allowing individual elements to have successive repeats. combinations_with_replacement(‘ABC’, 2) –> AA AB AC BB BC CC

permutations()

permutations(iterable[, r]) –> permutations object

Return successive r-length permutations of elements in the iterable.

permutations(range(3), 2) –> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)

_grouper()
dropwhile()

dropwhile(predicate, iterable) –> dropwhile object

Drop items from the iterable while predicate(item) is true. Afterwards, return every element until the iterable is exhausted.

izip_longest()

zip_longest(iter1 [,iter2 [...]], [fillvalue=None]) –> zip_longest object

Return a zip_longest object whose .__next__() method returns a tuple where the i-th element comes from the i-th iterable argument. The .__next__() method continues until the longest iterable in the argument sequence is exhausted and then it raises StopIteration. When the shorter iterables are exhausted, the fillvalue is substituted in their place. The fillvalue defaults to None or can be specified by a keyword argument.

groupby(iterable[, keyfunc]) → create an iterator which returns

(key, sub-iterator) grouped by each value of key(value).

combinations()

combinations(iterable, r) –> combinations object

Return successive r-length combinations of elements in the iterable.

combinations(range(4), 3) –> (0,1,2), (0,1,3), (0,2,3), (1,2,3)

_tee()

Iterator wrapped to make it copyable

count()

count(start=0, step=1) –> count object

Return a count object whose .__next__() method returns consecutive values. Equivalent to:

def count(firstval=0, step=1):

x = firstval while 1:

yield x x += step
BuiltinImporter()

Meta path import for built-in modules.

All methods are either class or static methods to avoid the need to instantiate the class.

imap()

map(func, *iterables) –> map object

Make an iterator that computes the function using arguments from each of the iterables. Stops when the shortest iterable is exhausted.

ifilter()

filter(function or None, iterable) –> filter object

Return an iterator yielding those items of iterable for which function(item) is true. If function is None, return the items that are true.

lazy_itertools.chain StrategyDict

This is a StrategyDict instance object called chain. Strategies stored: 2.

Strategy chain.chain (Default). Docstring starts with:

chain(*iterables) –> chain object

Strategy chain.star. An alias for it is chain.from_iterable. Docstring starts with:

chain.from_iterable(iterable) –> chain object

Note

This docstring is self-generated, see the StrategyDict class and the strategies docs for more details.

chain()

chain(*iterables) –> chain object

Return a chain object whose .__next__() method returns elements from the first iterable until it is exhausted, then elements from the next iterable, until all of the iterables are exhausted.

star()

chain.from_iterable(iterable) –> chain object

Alternate chain() contructor taking a single iterable argument that evaluates lazily.

lazy_itertools.izip StrategyDict

This is a StrategyDict instance object called izip. Strategies stored: 2.

Strategy izip.izip (Default). An alias for it is izip.smallest. Docstring starts with:

zip(iter1 [,iter2 [...]]) –> zip object

Strategy izip.longest. Docstring starts with:

zip_longest(iter1 [,iter2 [...]], [fillvalue=None]) –> zip_longest object

Note

This docstring is self-generated, see the StrategyDict class and the strategies docs for more details.

longest()

zip_longest(iter1 [,iter2 [...]], [fillvalue=None]) –> zip_longest object

Return a zip_longest object whose .__next__() method returns a tuple where the i-th element comes from the i-th iterable argument. The .__next__() method continues until the longest iterable in the argument sequence is exhausted and then it raises StopIteration. When the shorter iterables are exhausted, the fillvalue is substituted in their place. The fillvalue defaults to None or can be specified by a keyword argument.

izip()

zip(iter1 [,iter2 [...]]) –> zip object

Return a zip object whose .__next__() method returns a tuple where the i-th element comes from the i-th iterable argument. The .__next__() method continues until the shortest iterable in the argument sequence is exhausted and then it raises StopIteration.

lazy_itertools.accumulate StrategyDict

This is a StrategyDict instance object called accumulate. Strategies stored: 3.

Strategy accumulate.accumulate (Default). An alias for it is accumulate.itertools. Docstring starts with:

accumulate(iterable[, func]) –> accumulate object

Strategy accumulate.func. An alias for it is accumulate.pure_python. Docstring starts with:

Return series of accumulated sums.

Strategy accumulate.z. Docstring starts with:

Linear filters based on Z-transform frequency domain equations.

Note

This docstring is self-generated, see the StrategyDict class and the strategies docs for more details.

accumulate()[source]

accumulate(iterable[, func]) –> accumulate object

Return series of accumulated sums (or other binary function results).

func(iterable)

Return series of accumulated sums.