Skip to content

Commit e9eba13

Browse files
committed
Added documentation about lambda_operator
1 parent 8f22407 commit e9eba13

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

docs/pybeamline.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,31 @@ To transform the window into a DataFrame, the `sliding_window_to_log` operators
475475

476476
There are some utilities functionalities implemented in the library. They are listed below:
477477

478+
??? note "Details on `lambda_operator`"
479+
This function allows the definition of an operator according to a function defined somewhere else. It is the most flexible operator and, in case a value is return, then the pipeline will continue. If `None` is returned, then the pipeline does not continue.
480+
481+
The example below shows how this operator can be used to define custom filters and custom miners:
482+
```python
483+
from pybeamline.algorithms.lambda_operator import lambda_operator
484+
from pybeamline.sources.string_test_source import string_test_source
485+
486+
487+
def my_filter(event):
488+
return event if (event.get_event_name() == "A") else None
489+
490+
491+
def my_miner(event):
492+
return [('Start', event.get_event_name())]
493+
494+
495+
string_test_source(["ABCDE", "ACBDE"]).pipe(
496+
lambda_operator(my_filter),
497+
lambda_operator(my_miner)
498+
).subscribe(lambda x: print(str(x)))
499+
```
500+
501+
502+
478503
??? note "Details on `dfg_to_graphviz`"
479504
This function allows the transformation of the DFG produced with the `simple_dfg_miner` into the corresponding Graphviz string. It can be used for visualization of the model.
480505

0 commit comments

Comments
 (0)