Skip to content

[BUG] Error when printing adjointed BlockSparseVector #41

@mtfishman

Description

@mtfishman
julia> using BlockSparseArrays: BlockSparseVector

julia> a = BlockSparseVector{Float64}([2, 2])
2-blocked 4-element BlockSparseVector{Float64, Vector{Float64}, SparseArraysBase.SparseVectorDOK{Vector{Float64}, BlockSparseArrays.GetUnstoredBlock{Tuple{BlockArrays.BlockedOneTo{Int64, Vector{Int64}}}}}, Tuple{BlockArrays.BlockedOneTo{Int64, Vector{Int64}}}}:
 .
 .
 ─
 .
 .

julia> a'
1×4 adjoint(::BlockSparseVector{Float64, Vector{Float64}, SparseArraysBase.SparseVectorDOK{Vector{Float64}, BlockSparseArrays.GetUnstoredBlock{Tuple{BlockArrays.BlockedOneTo{Int64, Vector{Int64}}}}}, Tuple{BlockArrays.BlockedOneTo{Int64, Vector{Int64}}}}) with eltype Float64 with indices Base.OneTo(1)×BlockArrays.BlockedOneTo([2, 4]):
Error showing value of type LinearAlgebra.Adjoint{Float64, BlockSparseVector{Float64, Vector{Float64}, SparseArraysBase.SparseVectorDOK{Vector{Float64}, BlockSparseArrays.GetUnstoredBlock{Tuple{BlockArrays.BlockedOneTo{Int64, Vector{Int64}}}}}, Tuple{BlockArrays.BlockedOneTo{Int64, Vector{Int64}}}}}:
ERROR: MethodError: Cannot `convert` an object of type 
  CartesianIndex{2} to an object of type 
  CartesianIndex{1}
The function `convert` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  CartesianIndex{N}(::CartesianIndex{N}) where N
   @ Base multidimensional.jl:86
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:126

Stacktrace:
  [1] in(i::CartesianIndex{2}, indices::Dictionaries.Indices{CartesianIndex{1}})
    @ Dictionaries ~/.julia/packages/Dictionaries/tq7Jt/src/AbstractIndices.jl:73
  [2] isstored(::SparseArraysBase.SparseVectorDOK{Vector{Float64}, BlockSparseArrays.GetUnstoredBlock{Tuple{…}}}, ::Int64, ::Int64)
    @ SparseArraysBase ~/.julia/packages/SparseArraysBase/B5w8Y/src/sparsearraydok.jl:46
  [3] call(::SparseArraysBase.SparseArrayInterface, ::typeof(SparseArraysBase.isstored), ::LinearAlgebra.Adjoint{…}, ::Int64, ::Int64)
    @ SparseArraysBase ~/.julia/packages/SparseArraysBase/B5w8Y/src/wrappers.jl:128
  [4] isstored(::LinearAlgebra.Adjoint{LinearAlgebra.Adjoint{…}, SparseArraysBase.SparseVectorDOK{…}}, ::Int64, ::Int64)
    @ SparseArraysBase ./none:0
  [5] isstored(::SparseArraysBase.ReplacedUnstoredSparseArray{…}, ::Int64, ::Int64)
    @ SparseArraysBase ~/.julia/packages/SparseArraysBase/B5w8Y/src/abstractsparsearray.jl:46
  [6] isstored(a::SparseArraysBase.ReplacedUnstoredSparseArray{…}, I::CartesianIndex{…})
    @ SparseArraysBase ~/.julia/packages/SparseArraysBase/B5w8Y/src/abstractsparsearrayinterface.jl:58
  [7] viewblock(::BlockSparseArrays.ReplacedUnstoredBlockSparseArray{…}, ::BlockArrays.Block{…}, ::BlockArrays.Block{…})
    @ BlockSparseArrays ~/.julia/packages/BlockSparseArrays/SSspF/src/abstractblocksparsearray/views.jl:72
  [8] viewblock(a::BlockSparseArrays.ReplacedUnstoredBlockSparseArray{…}, block::BlockArrays.Block{…})
    @ BlockSparseArrays ~/.julia/packages/BlockSparseArrays/SSspF/src/abstractblocksparsearray/views.jl:63
  [9] view
    @ ~/.julia/packages/BlockArrays/8VbzB/src/abstractblockarray.jl:185 [inlined]
 [10] layout_getindex
    @ ~/.julia/packages/ArrayLayouts/QgP9t/src/ArrayLayouts.jl:138 [inlined]
 [11] getindex
    @ ~/.julia/packages/BlockArrays/8VbzB/src/abstractblockarray.jl:229 [inlined]
 [12] getindex
    @ ~/.julia/packages/BlockArrays/8VbzB/src/blockaxis.jl:5 [inlined]
 [13] getindex
    @ ~/.julia/packages/BlockArrays/8VbzB/src/blockaxis.jl:7 [inlined]
 [14] call(::BlockSparseArrays.BlockSparseArrayInterface, ::typeof(getindex), ::BlockSparseArrays.ReplacedUnstoredBlockSparseArray{…}, ::Int64, ::Int64)
    @ BlockSparseArrays ~/.julia/packages/BlockSparseArrays/SSspF/src/blocksparsearrayinterface/blocksparsearrayinterface.jl:87
 [15] (::DerivableInterfaces.InterfaceFunction{…})(::BlockSparseArrays.ReplacedUnstoredBlockSparseArray{…}, ::Vararg{…}; kwargs::@Kwargs{})
    @ DerivableInterfaces ~/.julia/packages/DerivableInterfaces/NzXbF/src/interface_function.jl:17
 [16] getindex(::BlockSparseArrays.ReplacedUnstoredBlockSparseArray{…}, ::Int64, ::Int64)
    @ BlockSparseArrays ~/.julia/packages/BlockSparseArrays/SSspF/src/abstractblocksparsearray/abstractblocksparsearray.jl:22
 [17] isassigned(::BlockSparseArrays.ReplacedUnstoredBlockSparseArray{…}, ::Int64, ::Int64)
    @ Base ./multidimensional.jl:1612
 [18] alignment(io::IOContext{…}, X::AbstractVecOrMat, rows::Vector{…}, cols::Vector{…}, cols_if_complete::Int64, cols_otherwise::Int64, sep::Int64, ncols::Int64)
    @ Base ./arrayshow.jl:68
 [19] _print_matrix(io::IOContext{…}, X::AbstractVecOrMat, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64, rowsA::UnitRange{…}, colsA::UnitRange{…})
    @ Base ./arrayshow.jl:207
 [20] print_matrix(io::IOContext{…}, X::BlockSparseArrays.ReplacedUnstoredBlockSparseArray{…}, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64)
    @ Base ./arrayshow.jl:171
 [21] print_matrix
    @ ./arrayshow.jl:171 [inlined]
 [22] print_array
    @ ./arrayshow.jl:358 [inlined]
 [23] show(io::IOContext{Base.TTY}, mime::MIME{Symbol("text/plain")}, a::LinearAlgebra.Adjoint{Float64, BlockSparseVector{…}})
    @ BlockSparseArrays ~/.julia/packages/BlockSparseArrays/SSspF/src/abstractblocksparsearray/wrappedabstractblocksparsearray.jl:393
 [24] (::OhMyREPL.var"#7#8"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::IOContext{Base.TTY})
    @ OhMyREPL ~/.julia/packages/OhMyREPL/bkUhZ/src/output_prompt_overwrite.jl:23
 [25] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/REPL/src/REPL.jl:661
 [26] display
    @ ~/.julia/packages/OhMyREPL/bkUhZ/src/output_prompt_overwrite.jl:6 [inlined]
 [27] display
    @ ~/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/REPL/src/REPL.jl:372 [inlined]
 [28] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:340
 [29] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL ~/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/REPL/src/REPL.jl:0
 [30] (::REPL.var"#70#71"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL ~/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/REPL/src/REPL.jl:378
 [31] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/REPL/src/REPL.jl:661
 [32] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL ~/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/REPL/src/REPL.jl:376
 [33] (::REPL.var"#do_respond#96"{})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL ~/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/REPL/src/REPL.jl:1003
 [34] (::OhMyREPL.Prompt.var"#24#51")(s::Any, data::Any, c::Any)
    @ OhMyREPL.Prompt ~/.julia/packages/OhMyREPL/bkUhZ/src/repl.jl:256
 [35] #invokelatest#2
    @ ./essentials.jl:1055 [inlined]
 [36] invokelatest
    @ ./essentials.jl:1052 [inlined]
 [37] (::REPL.LineEdit.var"#30#31"{OhMyREPL.Prompt.var"#24#51", String})(s::Any, p::Any)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/REPL/src/LineEdit.jl:1711
 [38] macro expansion
    @ ~/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/REPL/src/LineEdit.jl:2861 [inlined]
 [39] macro expansion
    @ ./lock.jl:273 [inlined]
 [40] (::REPL.LineEdit.var"#282#284"{})()
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/REPL/src/LineEdit.jl:2851
Some type information was truncated. Use `show(err)` to see complete types.

(jl_Mx2OHf) pkg> st
Status `/private/var/folders/qz/q22pzwm144z9fq57mpf1hfp40000gq/T/jl_Mx2OHf/Project.toml`
  [2c9a651f] BlockSparseArrays v0.2.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions