We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello,
In 1.10.0 view fails when:
julia> A = rand(2,3) 2×3 Matrix{Float64}: 0.562201 0.212601 0.193508 0.408022 0.978427 0.823557 julia> A[[CartesianIndex()], :, 1] 1×2 Matrix{Float64}: 0.562201 0.408022 julia> view(A, [CartesianIndex()], :, 1) ERROR: ArgumentError: number of indices (1) must match the parent dimensionality (2) Stacktrace: [1] check_parent_index_match(parent::Matrix{Float64}, #unused#::Tuple{Bool}) @ Base .\subarray.jl:43 [2] check_parent_index_match(parent::Matrix{Float64}, indices::Tuple{Vector{CartesianIndex{0}}, Base.Slice{Base.OneTo{Int64}}}) @ Base .\subarray.jl:41 [3] SubArray @ .\subarray.jl:21 [inlined] [4] SubArray @ .\subarray.jl:32 [inlined] [5] SubArray @ .\subarray.jl:28 [inlined] [6] unsafe_view @ .\subarray.jl:219 [inlined] [7] view(::Matrix{Float64}, ::Vector{CartesianIndex{0}}, ::Function, ::Int64) @ Base .\subarray.jl:180 [8] top-level scope @ REPL[11]:1
This shouldn't happen according to the second block of example.
Analysis of code brought the following lines:
julia/base/subarray.jl
Lines 207 to 210 in 94fd312
As we see, the condition holds because the length of J is 3 and ndims(A) is 2 and the last index is integer. Therefore view proceeds to the line 209.
ndims(A)
view
However, because of [CartesianIndex()], the array really needs to be reshaped.
[CartesianIndex()]
When I explicitly type line 211, it works as expected:
julia> A = rand(2,3) 2×3 Matrix{Float64}: 0.784263 0.958573 0.869377 0.619148 0.0324357 0.966875 julia> J = map(i->Base.unalias(A,i), to_indices(A, ([CartesianIndex()], :, 1))) ([CartesianIndex()], Base.Slice(Base.OneTo(2)), 1) julia> Base.unsafe_view(Base._maybe_reshape_parent(A, Base.index_ndims(J...)), J...) 1×2 view(::Matrix{Float64}, [CartesianIndex()], :, 1) with eltype Float64: 0.784263 0.619148
With best regards, Vadim Zborovskii
The text was updated successfully, but these errors were encountered:
SubArray: avoid invalid elimination of singleton indices (#53228)
4d0a469
close #53209
d497689
close #53209 (cherry picked from commit 4d0a469)
f2d56c7
SubArray: avoid invalid elimination of singleton indices (JuliaLang#5…
fd4343e
…3228) close JuliaLang#53209 (cherry picked from commit 4d0a469)
Successfully merging a pull request may close this issue.
Hello,
In 1.10.0 view fails when:
This shouldn't happen according to the second block of example.
Analysis of code brought the following lines:
julia/base/subarray.jl
Lines 207 to 210 in 94fd312
As we see, the condition holds because the length of J is 3 and
ndims(A)
is 2 and the last index is integer. Thereforeview
proceeds to the line 209.However, because of
[CartesianIndex()]
, the array really needs to be reshaped.When I explicitly type line 211, it works as expected:
With best regards, Vadim Zborovskii
The text was updated successfully, but these errors were encountered: