-
Notifications
You must be signed in to change notification settings - Fork 40
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
Concatenation of 3D OffsetArrays fails if their axes do not start at 1 #63
Comments
Also julia> hcat(zeros(2, 1:1, 2), zeros(2, 2:3, 2))
ERROR: BoundsError: attempt to access 2×3×2 Array{Float64,3} at index [1:2, 3:4, 1:2]
julia> vcat(zeros(1:1, 2, 2), zeros(2:3, 2, 2))
ERROR: BoundsError: attempt to access 3×2×2 Array{Float64,3} at index [3:4, 1:2, 1:2] but this works julia> hcat(zeros(2, 1:1, 2), zeros(2, 1:2, 2))
2×3×2 Array{Float64,3}:
[:, :, 1] =
0.0 0.0 0.0
0.0 0.0 0.0
[:, :, 2] =
0.0 0.0 0.0
0.0 0.0 0.0 Evidently the concatenations try to index into an |
Perhaps this should be fixed in |
The key problem, I think, is that cat lives in an "arrays are just lists, or lists-of-lists" world, and offset axes live in a world of "arrays are function-approximations over positions." Those two are not always compatible. In the offset-axes world, |
I agree, this is something that I was thinking of as well. However julia> hcat(zeros(2, 1:2), ones(2, 10:11))
2×4 Array{Float64,2}:
0.0 0.0 1.0 1.0
0.0 0.0 1.0 1.0
julia> hcat(zeros(2, 1:2), ones(2, -5:-4))
2×4 Array{Float64,2}:
0.0 0.0 1.0 1.0
0.0 0.0 1.0 1.0 Even the OP works if the third dimension is stripped julia> form = OffsetArray(reshape(zeros(Int8,0), 0, 0), 0:-1, 0:-1)
0×0 OffsetArray(::Array{Int8,2}, 0:-1, 0:-1) with eltype Int8 with indices 0:-1×0:-1
julia> exp = OffsetArray(reshape(zeros(Int8,0), 0, 16), 0:-1, 0:15)
0×16 OffsetArray(::Array{Int8,2}, 0:-1, 0:15) with eltype Int8 with indices 0:-1×0:15
julia> hcat(form, exp)
0×16 Array{Int8,2} |
Fair enough, if |
Repost from JuliaLang/julia#37628 1d case julia> vcat(zeros(2:3), zeros(4:5))
ERROR: ArgumentError: offset arrays are not supported but got an array with index other than 1
Stacktrace:
[1] require_one_based_indexing
@ ./abstractarray.jl:89 [inlined]
[2] setindex!
@ ./array.jl:855 [inlined]
[3] _typed_vcat(#unused#::Type{Float64}, V::Tuple{OffsetVector{Float64, Vector{Float64}}, OffsetVector{Float64, Vector{Float64}}})
@ Base ./abstractarray.jl:1450
[4] typed_vcat
@ ./abstractarray.jl:1518 [inlined]
[5] vcat(::OffsetVector{Float64, Vector{Float64}}, ::OffsetVector{Float64, Vector{Float64}})
@ Base ./abstractarray.jl:1433
[6] top-level scope
@ REPL[36]:1 |
One possible fairly straightforward rule would be drop all special indices along the direction of concatenation, and keep them when orthogonal. Thus Would this rule have weird consequences? |
I try to hcat an OffsetArray with indices (0:-1, 0:-1,0:1) and size=(0,0,2) with another OffsetArray with indices (0:-1,0:15,0:1) and size(0,16,2) and I get the error ERROR: BoundsError: attempt to access 0×16×2 Array{Int8,3} at index [1:0, 0:15, 1:2]
However if I try with arrays with regular indices
Thanks
The text was updated successfully, but these errors were encountered: