Alignment ops
TimeDag.left
— Functionleft(x, y[, alignment::Alignment; initial_values=nothing]) -> Node
Construct a node that ticks according to alignment
with the latest value of x
.
It is "left", in the sense of picking the left-hand of the two arguments x
and y
.
TimeDag.right
— Functionright(x, y[, alignment::Alignment; initial_values=nothing]) -> Node
Construct a node that ticks according to alignment
with the latest value of y
.
It is "right", in the sense of picking the right-hand of the two arguments x
and y
.
TimeDag.align
— Functionalign(x, y) -> Node
Form a node that ticks with the values of x
whenever y
ticks.
TimeDag.align_once
— Functionalign_once(x, y) -> Node
Similar to align(x, y)
, except knots from x
will be emitted at most once.
This means that the resulting node will tick at a subset of the times that y
ticks.
TimeDag.coalign
— Functioncoalign(x, [...; alignment::Alignment]) -> Node...
Given at least one node(s) x
, or values that are convertible to nodes, align all of them.
We guarantee that all nodes that are returned will have the same alignment. The values of each node will correspond to the values of the input nodes.
The choice of alignment is controlled by alignment
, which defaults to UNION
.
TimeDag.first_knot
— Functionfirst_knot(x::Node{T}) -> Node{T}
Get a node which ticks with only the first knot of x
, and then never ticks again.
TimeDag.active_count
— Functionactive_count(nodes...) -> Node{Int64}
Get a node of the number of the given nodes
(at least one) which are active.
TimeDag.prepend
— Functionprepend(x, y) -> Node
Create a node that ticks with knots from x
until y
is active, and thereafter from y
.
Note that the value_type
of the returned node will be that of the promoted value types of x
and y
.
TimeDag.throttle
— Functionthrottle(x::Node, n::Integer) -> Node
Return a node that only ticks every n
knots.
The first knot encountered on the input will always be emitted.
The throttled node is stateful and depends on the starting point of the evaluation.
TimeDag.lag
— Functionlag(x::Node, n::Integer)
Construct a node which takes values from x
, but lags them by n
knots.
This means that we do not introduce any new timestamps that do not appear in x
, however we will not emit knots for the first n
values that appear when evaluating x
.
If x
is a constant node, and n > 0
, lag(x, n)
will be an empty_node
of the same value_type
as x
.
Conceptually, this is consistent with the view that a constant is represented by a single knot at the start of time.
lag(x::Node, w::TimePeriod)
Construct a node which takes values from x
, but lags them by period w
.
For any constant, lagging by an amount of time is a no-op. This is because the constant is represented as a single value at the start of time (which will later appear at the start of the evaluation window).
Base.diff
— Functiondiff(x::Node[, n=1])
Compute the n
-knot difference of x
, i.e. x - lag(x, n)
.
TimeDag.count_knots
— Functioncount_knots(x) -> Node{Int64}
Return a node that ticks with the number of knots seen in x
since evaluation began.
Base.skip
— Functionskip(node::Node, n::Int)
Produces a TimeDag.Node
which is equal to x
less the first n
knots.
Base.merge
— Functionmerge(x::Node...) -> Node
Given at least one node x
, create a node that emits the union of knots from all x
.
If one or more of the inputs contain knots at the same time, then only one will be emitted. The last input in which a knot occurs at a particular time will take precedence.
If the inputs x
have different value types, then the resultant value type will be promoted as necessary to accommodate all inputs.