-
Notifications
You must be signed in to change notification settings - Fork 38
Functional Methods API
github-actions[bot] edited this page Apr 10, 2024
·
1 revision
Edges in CSP contain some methods to serve as syntactic sugar for stringing nodes together in a pipeline. This makes it easier to read/modify workflows and avoids the need for nested brackets.
Edge.apply(self, func, *args, **kwargs)
Calls csp.apply
on the edge with the provided python func
.
Args:
-
func
: A scalar function that will be applied on each value of the Edge. If a different output type is returned, pass a tuple(f, typ)
, wheretyp
is the output type of f -
args
: Positional arguments passed intofunc
-
kwargs
: Dictionary of keyword arguments passed into func
Edge.pipe(self, node, *args, **kwargs)
Calls the node
on the edge.
Args:
-
node
: A graph node that will be applied to the Edge, which is passed into node as the first argument. Alternatively, a(node, edge_keyword)
tuple whereedge_keyword
is a string indicating the keyword of node that expects the edge. -
args
: Positional arguments passed intonode
-
kwargs
: Dictionary of keyword arguments passed intonode
Edge.run(self, node, *args, **kwargs)
Alias for csp.run(self, *args, **kwargs)
import csp
from datetime import datetime, timedelta
import math
(csp.timer(timedelta(minutes=1))
.pipe(csp.count)
.pipe(csp.delay, timedelta(seconds=1))
.pipe((csp.sample, 'x'), trigger=csp.timer(timedelta(minutes=2)))
.apply((math.sin, float))
.apply(math.pow, 3)
.pipe(csp.firstN, 10)
.run(starttime=datetime(2000,1,1), endtime=datetime(2000,1,2)))
This wiki is autogenerated. To made updates, open a PR against the original source file in docs/wiki
.
Get Started (Tutorials)
Concepts
- CSP Node
- CSP Graph
- Historical Buffers
- Execution Modes
- Adapters
- Feedback and Delayed Edge
- Common Mistakes
How-to guides
- Use Statistical Nodes
- Create Dynamic Baskets
- Write Adapters:
- Profile CSP Code
References
- API Reference
- Glossary of Terms
- Examples
Developer Guide