Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in Base.vect if the elements have offset axes #44939

Closed
jishnub opened this issue Apr 11, 2022 · 1 comment · Fixed by #47893
Closed

Regression in Base.vect if the elements have offset axes #44939

jishnub opened this issue Apr 11, 2022 · 1 comment · Fixed by #47893
Milestone

Comments

@jishnub
Copy link
Contributor

jishnub commented Apr 11, 2022

This works on 1.7 and 1.8-beta3:

julia> using OffsetArrays

julia> ri = 2:3;

julia> [Base.IdentityUnitRange(ri), OffsetArray(ri, 2)]
2-element Vector{AbstractVector{Int64}}:
 Base.IdentityUnitRange(2:3)
 2:3 with indices 3:4

but on Version 1.9.0-DEV.353 (2022-04-09):

julia> using OffsetArrays

julia> ri = 2:3;

julia> [Base.IdentityUnitRange(ri), OffsetArray(ri, 2)]
ERROR: DimensionMismatch: axes must agree, got (Base.OneTo(2),) and (OffsetArrays.IdOffsetRange(values=3:4, indices=3:4),)
Stacktrace:
 [1] (::Base.var"#checkaxs#141")(axd::Tuple{Base.OneTo{Int64}}, axs::Tuple{OffsetArrays.IdOffsetRange{Int64, Base.OneTo{Int64}}})
   @ Base ./abstractarray.jl:1123
 [2] copyto_axcheck!
   @ ./abstractarray.jl:1125 [inlined]
 [3] Array
   @ ./array.jl:626 [inlined]
 [4] convert
   @ ./array.jl:617 [inlined]
 [5] setindex!(A::Vector{Vector{Int64}}, x::OffsetVector{Int64, UnitRange{Int64}}, i1::Int64)
   @ Base ./array.jl:966
 [6] copyto!(dest::Vector{Vector{Int64}}, src::Tuple{Base.IdentityUnitRange{UnitRange{Int64}}, OffsetVector{Int64, UnitRange{Int64}}})
   @ Base ./abstractarray.jl:909
 [7] vect(::Base.IdentityUnitRange{UnitRange{Int64}}, ::Vararg{Any})
   @ Base ./array.jl:147
 [8] top-level scope
   @ REPL[3]:1

The destination is chosen as Vector{Vector{Int64}}, which doesn't have offset axes.

@vtjnash
Copy link
Member

vtjnash commented Apr 11, 2022

Sounds like a possibly OffsetArrays bug (it needs to define a promotion rule that supersedes that for AbstractArray)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants