chainlet.primitives.chain module

class chainlet.primitives.chain.Chain(elements)

Bases: chainlet.primitives.compound.CompoundLink

A group of chainlets that sequentially process each data chunk

Parameters:elements (iterable[ChainLink]) – the chainlets making up this chain
Note:If elements contains a Chain, this is flattened and any sub-elements are directly included in the new Chain.

Slicing a chain guarantees consistency of the sum of parts and the chain. Linking an ordered, complete sequence of subslices recreates an equivalent chain.

chain == chain[:i] >> chain[i:]

Also, splitting a chain allows to pass values along the parts for equal results. This is useful if you want to inspect a chain at a specific position.

chain_result = chain.send(value)
temp_value = chain[:i].send(value)
split_result = chain[i:].send(temp_value)
chain_result == temp_value
Note:Some optimised chainlets may assimilate subsequent chainlets during linking. The rules for splitting chains still apply, though the actual chain elements may differ from the provided ones.
chain_fork

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

chain_join

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

chainlet_send(value=None)

Send a value to this element for processing

class chainlet.primitives.chain.FlatChain(elements)

Bases: chainlet.primitives.chain.Chain

A specialised Chain which never forks or joins internally

chain_fork = False
chain_join = False
chainlet_send(value=None)

Send a value to this element for processing

send(value=None)