References
Clock
RecordedArrays.AbstractClock — TypeAbstractClock{T<:Real}Supertype of clocks with time of type T.
RecordedArrays.DiscreteClock — TypeDiscreteClock([start], timelist)
DiscreteClock(stop)Clock for discrete-time process, time of which muse be increased with given step and can't be updated manually. The timelist must be a non-empty and monotonically increasing AbstractVector. If the start is not specified, the first item of timelist will be deleted and set as start. During iteration, the current time will be updated automatically and returned as iteration item. When the iteration finished without break, init! will be applied. DiscreteClock(stop) will create a clock with start=0 and timelist=Base.OneTo(stop)
Examples
julia> c = DiscreteClock(0:3);
julia> currenttime(c)
0
julia> [(t, currenttime(c)) for t in c]
3-element Vector{Tuple{Int64, Int64}}:
(1, 1)
(2, 2)
(3, 3)
julia> currenttime(c)
0
julia> c = DiscreteClock(3); # similar to DiscreteClock(0:3)
julia> (currenttime(c), collect(c))
(0, [1, 2, 3])RecordedArrays.ContinuousClock — TypeContinuousClock{T, I<:Union{Nothing, DiscreteClock}} <: AbstractClock{T}
ContinuousClock(stop, [start=zero(stop)]; [max_epoch=nothing])A clock for continuous-time process. Unlike the DiscreteClock, during iteration, the current time will not be update automatically, but update by increase! manually. Besides the epoch of current iteration instead of current time will be returned. If the max_epoch is specified, the iteration will break when epoch reach to the max_epoch, even currenttime(c) < limit(c), and break in this way the init!(c) will not be applied.
Examples
julia> c = ContinuousClock(3.0; max_epoch=2);
julia> for epoch in c
increase!(c, 1)
println(currenttime(c), ' ', epoch)
end
1.0 1
2.0 2
julia> for epoch in c
increase!(c, 1)
println(currenttime(c), ' ', epoch)
end
3.0 1
julia> for epoch in c
increase!(c, 1)
println(currenttime(c), ' ', epoch)
end
1.0 1
2.0 2RecordedArrays.currenttime — Functioncurrenttime(c::AbstractClock)Return current time of clock c.
RecordedArrays.limit — Functionlimit(c::AbstractClock)Return the limit of clock c. For a ContinuousClock c, the max time might larger than limit(c).
RecordedArrays.start — Functionstart(c::AbstractClock)Return the start time of clock c.
RecordedArrays.init! — Functioninit!(c::AbstractClock)Update current time to start time.
RecordedArrays.increase! — Functionincrease!(c::ContinuousClock, t::Real)Update current time of clock c to currenttime(c) + t.
Entries
RecordedArrays.AbstractEntry — TypeAbstractEntry{V,T<:Real}Supertype of all entry types, which store changes of a specified variable of type V with timestamps of type T.
RecordedArrays.StaticEntry — TypeStaticEntry{V,T} <: AbstractEntry{V,T}Entry type to store changing history of a variable whose value not changing overtime.
RecordedArrays.DynamicEntry — TypeDynamicEntry{V,T} <: AbstractEntry{V,T}Entry type to store changing history of a variable whose value changing overtime.
RecordedArrays.getts — Functiongetts(e::AbstractEntry{V,T}) -> Vector{T}Get timestamps of an entry e.
RecordedArrays.getvs — Functiongetvs(e::AbstractEntry{V,T}) -> Vector{V}Get values at each timestamp of an entry e.
RecordedArrays.tspan — Functiontspan(e::AbstractEntry{V,T}) -> TGet last time of an entry e.
RecordedArrays.gettime — Functiongettime([alg::AbstractSearch], e::AbstractEntry, t::Real)
gettime([alg::AbstractSearch], e::AbstractEntry, ts)
gettime([alg::AbstractSearch], es::AbstractArray{<:AbstractEntry}, t::Real)
gettime([alg::AbstractSearch], es::AbstractArray{<:AbstractEntry}, ts)Get the value of e at t::Real or values at each time t in an iterate ts. If t is not a timestamp in getts(e), return value at time getts(e)[i] where getts(e)[i] < t < getts(e)[i+1]. The alg is a search algorithm that finds the index i of a target time t, which can be LinearSearch or BinarySearch (by default). For es, an array of entries, return values at t as a similar array.
ts must be monotonically increasing.
RecordedArrays.store! — Functionstore!(e::AbstractEntry, v, t::Union{Real,AbstractClock})Store a entry with value v at time t.
RecordedArrays.del! — Functiondel!(e::AbstractEntry, t::Union{Real,AbstractClock})Marks a entry e deleted at time t. If an AbstractClock c is given, t = currenttime(c).
Recorded Types
RecordedArrays.AbstractRecArray — TypeAbstractRecArray{T,N}Supertype of recorded N-dimensional arrays with elements of type T, whose changes will be recorded automatically.
Avoid to mutate recorded arrays out of loop, because clocks will initial automatically during loop.
RecordedArrays.RecordedNumber — TypeRecordedNumber{T}A Union of recorded numbers with type T.
RecordedNumber{S} <: T will always return false where T is a subtype of Number, even if S <: T. There is a function issubtype(RecordedNumber{S}, T) which would return true if S <: T. Besides, isnum(T, n::RecordedNumber{S}) would return true if S <: T.
Store a value v to an RecordedNumber x by x[] = v or x[1] = v instead of x = v.
RecordedArrays.recorded — Functionrecorded(E, c::AbstractClock, A)Create a recorded array (or number) with entry of type E and clock c.
RecordedArrays.state — Functionstate(A::AbstractRecArray{T,N}) -> Array{T,N}
state(x::RecordedNumber{T}) -> TGet current state of a recorded array A or a recorded number x.
state for AbstractRecArray{V,T,N} where N >= 2 may be unsafe because of unsafe_wrap and unsafe_convert.
RecordedArrays.getentries — Functiongetentries(x::RecordedNumber)Get entries of a recorded number x.
getentries(A::AbstractRecArray)Get entries of a recorded array A.
RecordedArrays.issubtype — Functionissubtype(S, T) -> BoolSimilar to S <: T, but for a S where S <: RecordedNumber{P}, return true if P <: T.
RecordedArrays.isnum — Functionisnum(T, x) -> BoolSimilar to x is T, but for x where x::RecordedNumber{S}, return true if S <:T.
Utilities
RecordedArrays.MCIndices — TypeMCIndices(sz::NTuple{N,AbstractVector{Int}}) -> R
MCIndices(A::AbstractArray) -> RA CartesianIndices like type defines mutable and disconnected region R.
Examples
julia> im = MCIndices(([1, 3], [2, 4]))
2×2 MCIndices{2}:
(1, 2) (1, 4)
(3, 2) (3, 4)
julia> im[1]
(1, 2)
julia> im[1, 2]
(1, 4)RecordedArrays.DOKSparseArray — TypeDOKSparseArray{T,N}A simple sparse array type storing as DOK format.