Skip to content

Merge of two VNTs can drop results when one contains a PartialArray and the other a full Array #1245

@penelopeysm

Description

@penelopeysm
julia> vnt1 = @vnt begin x = [1.0, 2.0] end
VarNamedTuple
└─ x => [1.0, 2.0]

julia> vnt2 = @vnt begin
           @template x = zeros(2)
           x[1] = 3.0
       end
VarNamedTuple
└─ x => PartialArray size=(2,) data::Vector{Float64}
        └─ (1,) => 3.0

julia> merge(vnt1, vnt2)
VarNamedTuple
└─ x => PartialArray size=(2,) data::Vector{Float64}
        └─ (1,) => 3.0

It is a bit unintuitive that x[2] is dropped here. This happens because merge can't line the two up: it just thinks "okay, one is a PA and one is an array and they're different things, so I'll just overwrite the first one". I don't really know what the solution to this is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions