Notes on new features (minor releases). For more details on bugfixes and non-feature-adding changes (patch releases), check out the releases page.
- Calling
axes
on aComponentArray
returns a newCombinedAxis
type!- Doing things The Right Way™!
- No more complicated and error-prone custom broadcasting machinery!
- No more wierd special cases!
- All indexing now slices rather than sometimes viewing and sometimes slicing!
- Property access methods (i.e. "dot-access") still use views!
julia> x = ComponentArray(a=1, b=[4,2])
ComponentVector{Int64}(a = 1, b = [4, 2])
julia> x.b # Dot-access still views by default
2-element view(::Vector{Int64}, 2:3) with eltype Int64:
4
2
julia> x[:b] # Slicing now slices
2-element Vector{Int64}:
4
2
julia> @view x[:b] # Use @view to view
2-element view(::Vector{Int64}, 2:3) with eltype Int64:
4
2
- Construct
ComponentArray
s fromDict
s!
julia> d = Dict(:a=>rand(3), :b=>rand(2,2))
Dict{Symbol, Array{Float64, N} where N} with 2 entries:
:a => [0.996693, 0.148683, 0.203083]
:b => [0.68759 0.41585; 0.900591 0.377475]
julia> ComponentArray(d)
ComponentVector{Float64}(a = [0.9966932920820444, 0.14868304847436709, 0.20308284992079573], b = [0.6875902095731583 0.415850281435181; 0.9005909643364229 0.3774747843717925])
- Generated
valkeys
function for fast iteration overComponentVector
subcomponents!
julia> ca = ComponentArray(a=1, b=[1,2,3], c=(a=4,))
ComponentVector{Int64}(a = 1, b = [1, 2, 3], c = (a = 4))
julia> valkeys(ca)
(Val{:a}(), Val{:b}(), Val{:c}())
julia> [ca[k] for k in valkeys(ca)]
3-element Array{Any,1}:
1
[1, 2, 3]
ComponentVector{Int64,SubArray...}(a = 4)
julia> @btime sum(prod($ca[k]) for k in valkeys($ca))
11.511 ns (0 allocations: 0 bytes)
11
- Much faster (and lazier) arrays of subcomponents!
julia> ca = ComponentArray(a=5, b=(a=zeros(4,4), b=0), c=(a=[(a=1, b=2), (a=3, b=1), (a=1, b=2), (a=3, b=1)], b=[1., 2., 4]));
julia> @btime sum(x.a + x.b for x in $ca.c.a);
127.160 ns (2 allocations: 480 bytes)
julia> @btime sum(x.a + x.b for x in $ca.c.a);
36.895 ns (0 allocations: 0 bytes)
- Easier DifferentialEquations plotting!
- Automatic legend labeling!
Symbol
andString
support for thevars
plot keyword!- See it in an action here!
- Constructor for making new
ComponentVector
s with additional fields! Watch out, it's slow!
julia> x = ComponentArray(a=5, b=[1, 2])
ComponentVector{Int64}(a = 5, b = [1, 2])
julia> moar_x = ComponentArray(x; c=zeros(2,2), d=(a=2, b=10))
ComponentVector{Int64}(a = 5, b = [1, 2], c = [0 0; 0 0], d = (a = 2, b = 10))
- Zygote rules for DiffEqFlux support! Check out the docs for an example!
- Matrix and higher-dimensional array components!
...and plenty more!