-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
arrays[a, r, r, a, y, s][a, r, r, a, y, s]
Description
we could creat a SubArray
with a float index like:
julia> A = rand(2,3);
julia> B = @views A[[1.0,2.0]];
julia> typeof(B)
SubArray{Float64, 1, Vector{Float64}, Tuple{Vector{Float64}}, false}
but it's unusable when index a Subarray
above:
julia> B[1]
ERROR: ArgumentError: invalid index: 1.0 of type Float64
Stacktrace:
[1] to_index(i::Float64)
@ Base .\indices.jl:300
[2] to_index(A::Vector{Float64}, i::Float64)
@ Base .\indices.jl:277
[3] _to_indices1(A::Vector{Float64}, inds::Tuple{Base.OneTo{Int64}}, I1::Float64)
@ Base .\indices.jl:359
[4] to_indices
@ .\indices.jl:354 [inlined]
[5] to_indices
@ .\indices.jl:345 [inlined]
[6] getindex
@ .\abstractarray.jl:1290 [inlined]
[7] getindex(V::SubArray{Float64, 1, Vector{Float64}, Tuple{Vector{Float64}}, false}, I::Int64)
@ Base .\subarray.jl:290
[8] top-level scope
@ REPL[11]:1
version and platform:
julia> versioninfo()
Julia Version 1.10.10
Commit 95f30e51f4 (2025-06-27 09:51 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 12 × 11th Gen Intel(R) Core(TM) i5-11500H @ 2.90GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, tigerlake)
Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)
Metadata
Metadata
Assignees
Labels
arrays[a, r, r, a, y, s][a, r, r, a, y, s]