https://github.com/wangl-cc/recordedarrays.jl
Record changes of your array automatically.
https://github.com/wangl-cc/recordedarrays.jl
arrays julia
Last synced: over 1 year ago
JSON representation
Record changes of your array automatically.
- Host: GitHub
- URL: https://github.com/wangl-cc/recordedarrays.jl
- Owner: wangl-cc
- License: mit
- Created: 2021-03-24T08:13:48.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-03-02T01:25:19.000Z (over 4 years ago)
- Last Synced: 2025-02-25T09:49:24.906Z (over 1 year ago)
- Topics: arrays, julia
- Language: Julia
- Homepage:
- Size: 10.9 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RecordedArrays.jl
[](https://github.com/wangl-cc/RecordedArrays.jl/actions/workflows/ci.yml)
[](https://juliahub.com/ui/Packages/RecordedArrays/TOzPf)
[](https://codecov.io/gh/wangl-cc/RecordedArrays.jl)
[](https://github.com/wangl-cc/RecordedArrays.jl/blob/master/LICENSE)
[](https://wangl-cc.github.io/RecordedArrays.jl/stable)
[](https://wangl-cc.github.io/RecordedArrays.jl/dev)
During running a simulation, one of the most important but annoying part is
recording and processing the changing values of state.
This package provides "recorded" types,
changes of which will be recorded automatically.
**Note:** There are huge changes between `v0.3` and `v0.4`.
You can not load and process data of `v0.3` with `v0.4`.
## Installation
This is a registered package, it can be installed with the `add` command in
the Pkg REPL:
```
pkg> add RecordedArrays
```
## Quick Start
```julia
julia> using RecordedArrays # load this package
julia> c = ContinuousClock(3); # define a clock
julia> v = recorded(DynamicEntry, c, [0, 1]) # create a recorded array with the clock
2-element recorded(::Vector{Int64}):
0
1
julia> v + v # math operations work as normal array
2-element Vector{Int64}:
0
2
julia> v .* v # broadcast works as normal array as well
2-element Vector{Int64}:
0
1
julia> increase!(c, 1) # when time goes and array changes, increase the define clock firstly
1
julia> v[1] += 1 # change array's element
1
julia> increase!(c, 1) # when time goes and array changes, increase the define clock firstly
2
julia> push!(v, 1) # push a new element
3-element recorded(::Vector{Int64}):
1
1
1
julia> es = getentries(v) # view recorded changes
3-element Vector{DynamicEntry{Int64, Int64}}:
DynamicEntry{Int64, Int64}([0, 1], [0, 1])
DynamicEntry{Int64, Int64}([1], [0])
DynamicEntry{Int64, Int64}([1], [2])
julia> es[1] # the changes of the first element of `v`, which changed to 1 at `t=1`
DynamicEntry{Int64, Int64} with timestamps:
0
1
julia> gettime(es[1], 0:2) # get the value of the first element at time 0, 1 and 2
3-element Vector{Int64}:
0
1
1
julia> es[3] # the changes of the third element of `v`, which was pushed at `t=2`
DynamicEntry{Int64, Int64} with timestamps:
2
julia> gettime(es[3], 0:2) # get the value of the first element at time 0, 1 and 2
3-element Vector{Int64}:
0
0
1
```