jonniedie / ComponentArrays.jl

Arrays with arbitrarily nested named components.
MIT License
291 stars 35 forks source link

Easily unpack components to static arrays #219

Closed jonniedie closed 1 year ago

jonniedie commented 1 year ago
julia> using ComponentArrays

julia> ca = ComponentArray(a=5, b=[4, 1], c = [1 2; 3 4], d=(a=2, b=[6, 30.0]))
ComponentVector{Float64}(a = 5.0, b = [4.0, 1.0], c = [1.0 2.0; 3.0 4.0], d = (a = 2.0, b = [6.0, 30.0]))

julia> @static_unpack a, b, c, d = ca
ComponentVector{Float64,SubArray...}(a = 2.0, b = [6.0, 30.0])

julia> a
5.0

julia> b
2-element SVector{2, Float64} with indices SOneTo(2):
 4.0
 1.0

julia> c
2×2 SMatrix{2, 2, Float64, 4} with indices SOneTo(2)×SOneTo(2):
 1.0  2.0
 3.0  4.0

julia> d
ComponentVector{Float64,SubArray...}(a = 2.0, b = [6.0, 30.0])
codecov-commenter commented 1 year ago

Codecov Report

Merging #219 (dc0103a) into main (18632e7) will increase coverage by 0.93%. The diff coverage is 100.00%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##             main     #219      +/-   ##
==========================================
+ Coverage   72.51%   73.44%   +0.93%     
==========================================
  Files          21       21              
  Lines         684      708      +24     
==========================================
+ Hits          496      520      +24     
  Misses        188      188              
Files Changed Coverage Δ
src/ComponentArrays.jl 100.00% <ø> (ø)
src/compat/static_arrays.jl 100.00% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

jonniediegelman commented 1 year ago

FYI @jondavis847

ChrisRackauckas commented 1 year ago

What in this is breaking? This is the only change in the breaking v0.15 release but I don't quite see how it breaks previous behavior.

jonniedie commented 1 year ago

Oh geez you're right. Actually nothing. I was kinda just on autopilot from working on things that are in versions >1.0 and forgot that 0.x changes are breaking for versions <1.0. I don't think I can revert it at this point, though, right?

ChrisRackauckas commented 1 year ago

yeah no reason to revert, I was just confused.