Miscellaneous

Arrays & indexing

Base.getindexFunction
getindex(x::Node, args...)

A node whose values are generated by calling getindex(value, args...) on each value obtained from the node x.

source
Base.vecFunction
vec(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.

source

Random

Base.randFunction
rand([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, S will be one of

    • the element type
    • a set of values from which to select

    S will default to Float64 otherwise.

  • If specified, dims should be a tuple or vararg of integers representing the dimensions of an array.

Note

The values of the knots from alignment will be ignored.

Note

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.

Tip

If provided, rng will be copied before it is used. This is to ensure reproducability when evaluating a node multiple times.

source

Conditional

Base.filterFunction
filter(f::Function, x::Node) -> Node

Obtain 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.

source
Base.skipmissingFunction
skipmissing(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.

source
TimeDag.zap_untilFunction
zap_until(x::Node, t) -> Node

Given a node x, return a node in which all knots strictly before t are omitted.

source

Type conversion

TimeDag.convert_valueFunction
convert_value(T, x::Node[; upcast=false]) -> Node

Convert 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.

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)
String

Note 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
source