This is a super lightweight package that exports two functions: index
and slice
. These functions have helped to ease the burden of handling messy indexing into trajectory data vectors of the form
where each element dim = n + m
, we can use slice
and index
, to extract what we want from
- extract
$z_t$ :zₜ = Z⃗[slice(t, dim)]
- extract
$x_t$ :xₜ = Z⃗[slice(t, 1:n, dim)]
- extract
$u_t$ :uₜ = Z⃗[slice(t, (1:m) .+ n, dim)]
- extract
$i$ -th component of$x_t$ :xₜⁱ = Z⃗[index(t, i, dim)]
- extract
$j$ -th component of$u_t$ :uₜʲ = Z⃗[index(t, j + n, dim)]
With this, the user is still responsible for keeping track of the component indices for
TrajectoryIndexingUtils.jl is registered! Install in the REPL by entering pkg mode with ]
and then running
pkg> add TrajectoryIndexingUtils
index(t::Int, dim::Int) -> zₜ[dim]
index(t::Int, pos::Int, dim::Int) -> zₜ[pos]
slice(t::Int, dim::Int; stretch=0) -> zₜ[1:dim + stretch] # can be used to extract, e.g., [xₜ; xₜ₊₁], with stretch = dim
slice(t::Int, pos::Int, dim::Int) -> zₜ[1:pos]
slice(t::Int, pos1::Int, pos2::Int, dim::Int) -> zₜ[pos1:pos2]
slice(t::Int, indices::AbstractVector{Int}, dim::Int) -> zₜ[indices]
slice(ts::UnitRange{Int}, dim::Int) -> vec(zₜ for t ∈ ts)
This package uses a Documenter config that is shared with many of our other repositories. To build the docs, you will need to run the docs setup script to clone and pull down the utility.
# first time only
./docs/get_docs_utils.sh # or ./get_docs_utils.sh if cwd is in ./docs/
To build the docs pages:
julia --project=docs docs/make.jl
or editing the docs live:
julia --project=docs
> using LiveServer, Piccolo, Revise
> servedocs(skip_files=["docs/src/index.md"])
Note:
servedocs
needs to watch a subset of the files in thedocs/
folder. If it watches files that are generated on a docs build/re-build,servedocs
will continuously try to re-serve the pages.To prevent this, ensure all generated files are included in the skip dirs or skip files args for
servedocs
.
For example, if we forget index.md like so:
julia --project=docs
> using LiveServer, Piccolo, Revise
> servedocs()
it will not build and serve.
"It seems that perfection is attained not when there is nothing more to add, but when there is nothing more to take away." - Antoine de Saint-Exupéry