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

views with Vector{Bool} indices are broken #334

Closed
SebastianM-C opened this issue Jan 15, 2024 · 1 comment
Closed

views with Vector{Bool} indices are broken #334

SebastianM-C opened this issue Jan 15, 2024 · 1 comment
Assignees
Labels

Comments

@SebastianM-C
Copy link
Contributor

Hi! I've noticed that v3 breaks views when using Boolean masks for the indices.

MWE

using RecursiveArrayTools
a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
vA = VectorOfArray(a)

@view vA[:, Bool[1,0,1]]

Error & Stacktrace ⚠️

3×2 view(::VectorOfArray{Int64, 2, Vector{Vector{Int64}}}, :, [1, 3]) with eltype Int64:
Error showing value of type SubArray{Int64, 2, VectorOfArray{Int64, 2, Vector{Vector{Int64}}}, Tuple{Base.Slice{Base.OneTo{Int64}}, Base.LogicalIndex{Int64, Vector{Bool}}}, false}:
ERROR: CanonicalIndexError: getindex not defined for Base.LogicalIndex{Int64, Vector{Bool}}
Stacktrace:
  [1] error_if_canonical_getindex(::IndexCartesian, A::Base.LogicalIndex{Int64, Vector{Bool}}, ::Int64)
    @ Base .\abstractarray.jl:1307
  [2] getindex
    @ Base .\abstractarray.jl:1287 [inlined]
  [3] reindex
    @ Base .\subarray.jl:266 [inlined]
  [4] reindex
    @ Base .\subarray.jl:262 [inlined]
  [5] isassigned(::SubArray{Int64, 2, VectorOfArray{Int64, 2, Vector{Vector{Int64}}}, Tuple{Base.Slice{Base.OneTo{Int64}}, Base.LogicalIndex{Int64, Vector{Bool}}}, false}, ::Int64, ::Int64)
    @ Base .\subarray.jl:360
  [6] alignment(io::IOContext{Base.TTY}, X::AbstractVecOrMat, rows::Vector{Int64}, cols::Vector{Int64}, cols_if_complete::Int64, cols_otherwise::Int64, sep::Int64, ncols::Int64)
    @ Base .\arrayshow.jl:68
  [7] _print_matrix(io::IOContext{Base.TTY}, X::AbstractVecOrMat, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64, rowsA::UnitRange{Int64}, colsA::UnitRange{Int64})
    @ Base .\arrayshow.jl:207
  [8] print_matrix(io::IOContext{Base.TTY}, X::SubArray{Int64, 2, VectorOfArray{…}, Tuple{…}, false}, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64)
    @ Base .\arrayshow.jl:171
  [9] print_matrix(io::IO, X::AbstractVecOrMat, pre::AbstractString, sep::AbstractString, post::AbstractString, hdots::AbstractString, vdots::AbstractString, ddots::AbstractString, hmod::Integer, vmod::Integer)
    @ Base .\arrayshow.jl:171 [inlined]
 [10] print_array
    @ .\arrayshow.jl:358 [inlined]
 [11] show(io::IOContext{Base.TTY}, ::MIME{Symbol("text/plain")}, X::SubArray{Int64, 2, VectorOfArray{Int64, 2, Vector{Vector{Int64}}}, Tuple{Base.Slice{Base.OneTo{Int64}}, Base.LogicalIndex{Int64, Vector{Bool}}}, false})
    @ Base .\arrayshow.jl:399
 [12] (::REPL.var"#55#56"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
    @ REPL C:\Users\sebastian\.julia\juliaup\julia-1.10.0+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:273
 [13] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL C:\Users\sebastian\.julia\juliaup\julia-1.10.0+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:569
 [14] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
    @ REPL C:\Users\sebastian\.julia\juliaup\julia-1.10.0+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:259
 [15] display(d::REPL.REPLDisplay, x::Any)
    @ REPL C:\Users\sebastian\.julia\juliaup\julia-1.10.0+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:278
 [16] display(x::Any)
    @ Base.Multimedia .\multimedia.jl:340
 [17] #invokelatest#2
    @ .\essentials.jl:887 [inlined]
 [18] invokelatest
    @ .\essentials.jl:884 [inlined]
 [19] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL C:\Users\sebastian\.julia\juliaup\julia-1.10.0+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:315
 [20] (::REPL.var"#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL C:\Users\sebastian\.julia\juliaup\julia-1.10.0+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:284
 [21] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL C:\Users\sebastian\.julia\juliaup\julia-1.10.0+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:569
 [22] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL C:\Users\sebastian\.julia\juliaup\julia-1.10.0+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:282
 [23] (::REPL.var"#do_respond#80"{Bool, Bool, REPL.var"#93#103"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL C:\Users\sebastian\.julia\juliaup\julia-1.10.0+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:911
 [24] (::VSCodeServer.var"#101#104"{REPL.var"#do_respond#80"{Bool, Bool, REPL.var"#93#103"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt}})(mi::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool)
    @ VSCodeServer c:\Users\sebastian\.vscode\extensions\julialang.language-julia-1.66.2\scripts\packages\VSCodeServer\src\repl.jl:122
 [25] #invokelatest#2
    @ Base .\essentials.jl:887 [inlined]
 [26] invokelatest
    @ Base .\essentials.jl:884 [inlined]
 [27] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit C:\Users\sebastian\.julia\juliaup\julia-1.10.0+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\LineEdit.jl:2656
 [28] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL C:\Users\sebastian\.julia\juliaup\julia-1.10.0+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:1312
 [29] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL C:\Users\sebastian\.julia\juliaup\julia-1.10.0+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:386
Some type information was truncated. Use `show(err)` to see complete types.

Environment (please complete the following information):

  • Output of using Pkg; Pkg.status()
  [731186ca] RecursiveArrayTools v3.5.3
  • Output of versioninfo()
julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39 (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 16 × AMD Ryzen 7 5800H with Radeon Graphics
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, znver3)
  Threads: 23 on 16 virtual cores
Environment:
  JULIA_EDITOR = code
@AayushSabharwal
Copy link
Member

#335

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

No branches or pull requests

3 participants