Skip to content

Setting OffsetArray(::StaticArray) falling back to Vector #153

@marius311

Description

@marius311

@set! is awesome for StaticArrays,

julia> x = @SVector(zeros(Int,3))
3-element SVector{3, Int64} with indices SOneTo(3):
 0
 0
 0

julia> @set x[1] = 1
3-element SVector{3, Int64} with indices SOneTo(3):
 1
 0
 0

but if the array if OffsetArray(::StaticArray), it seems to fall back to OffsetArray(::Array).

julia> x = OffsetArray(@SVector(zeros(Int,3)),-1)
3-element OffsetArray(::SVector{3, Int64}, 0:2) with eltype Int64 with indices 0:2:
 0
 0
 0

julia> @set x[1] = 1
3-element OffsetArray(::Vector{Int64}, 0:2) with eltype Int64 with indices 0:2:
 0
 1
 0

Is there some special-case I could define in my session to handle this? Could this be fixed generally?

Julia 1.6 / Setfield v0.7.0 / StaticArrays v1.0.1 / OffsetArrays v1.5.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions