Miscellaneous
Arrays & indexing
Base.getindex — Functiongetindex(x::Node, args...)A node whose values are generated by calling getindex(value, args...) on each value obtained from the node x.
Base.vec — Functionvec(x::Node{<:AbstractArray}) -> Node{<:AbstractVector}Return a vector whose values are those of x, but flattened into a single vector.
If x has values which are already an AbstractVector, this will be a no-op.
Random
Base.rand — Functionrand([rng=...,] alignment::Node[, S, dims...])Generate random numbers aligned to alignment, with the given rng if provided.
Semantics are otherwise very similar to the usual Base.rand:
If specified,
Swill be one of- the element type
- a set of values from which to select
Swill default toFloat64otherwise.If specified,
dimsshould be a tuple or vararg of integers representing the dimensions of an array.
The values of the knots from alignment will be ignored.
The default value of rng on Julia 1.6 is MersenneTwister(). On Julia 1.7 and later it is Xoshiro(). This matches the default random number generator used in the language.
If provided, rng will be copied before it is used. This is to ensure reproducability when evaluating a node multiple times.
Conditional
Base.filter — Functionfilter(f::Function, x::Node) -> NodeObtain a node that removes knots for which f(value) is false.
The value_type of the returned node is the same as that for the input x.
Base.skipmissing — Functionskipmissing(x::Node{T}) -> Node{nonmissingtype(T)}Obtain a node which ticks with the values of x, so long as that value is not missing.
The value_type of the node that is returned will always be the nonmissingtype of the value_type of x.
In the case that x cannot tick with missing (based on its value_type), we just return x.
TimeDag.zap_until — Functionzap_until(x::Node, t) -> NodeGiven a node x, return a node in which all knots strictly before t are omitted.
Type conversion
TimeDag.convert_value — Functionconvert_value(T, x::Node[; upcast=false]) -> NodeConvert the values of node x to type T.
The value type of the resulting node is guaranteed to be T if and only if upcast=true. See further discussion in the note.
By default, convert_value has similar semantics to Base.convert, which means that the value_type of the returned node might be a subtype of T.
A concrete example:
julia> x = convert_value(Any, constant("hello"));
julia> value_type(x)
StringNote that the same thing would happen if calling convert(Any, "hello").
However, if we set upcast=true:
julia> x = convert_value(Any, constant("hello"); upcast=true);
julia> value_type(x)
Any