Meta¶
Elements:
|
Set static context for this sequence. |
Store static context. |
|
Update runtime context with the static one. |
Metaprogramming:
|
Merge common heads of sequences seqs. |
Elements¶
- class SetContext(key, value)[source]¶
Set static context for this sequence.
Static context does not automatically update runtime context. Use
UpdateContextFromStaticfor that.Static context can be used during the initialisation phase to set output directories,
Cachenames, etc. There is no way to update static context from runtime one.key is a string representing a (possibly nested) dictionary key. value is its value.
value can be a formatting string. See
format_context()for details.If value could not be formatted,
LenaKeyErroris raised.
Metaprogramming¶
These functions allow transformations of Lena sequences.
- merge_heads(*seqs)[source]¶
Merge common heads of sequences seqs.
Equal elements are merged into a common sequence, first unequal ones are put into a
Splitand recursively merged with similar ones. To be able to be merged, sequence elements must support equality comparison.This class can optimize processing same data with several sequences in different modules by reading that data once and processing that simultaneously. Example:
s1 = Source( ReadData(), Process1(), ) s2 = Source( ReadData(), Process2(), ) merged = merge_heads(s1, s2) # merged is Source( ReadData(), Split([ Process1(), Process2(), ]), ) # merge_heads(s1, s1) is s1
seqs are Lena sequences. They must be of the same type (for example
Source).Added in version 0.6.